From 3b01205585eb364dbfb1250d666c35610b19e62d Mon Sep 17 00:00:00 2001 From: Jonas Holmberg Date: Mon, 8 Jan 2024 12:11:40 +0100 Subject: [PATCH] spa: Fix sign conversion in SPA_IS_ALIGNED Fix the following compiler warning: | In file included from /usr/include/spa-0.2/spa/utils/dict.h:14, | from ../src/util_pipewire_objects.c:15: | /usr/include/spa-0.2/spa/utils/defs.h: In function 'spa_ptr_inside_and_aligned': | /usr/include/spa-0.2/spa/utils/defs.h:275:56: error: conversion to 'long unsigned int' from 'long int' may change the sign of the result [-Werror=sign-conversion] | 275 | #define SPA_PTR_ALIGNMENT(p,align) ((intptr_t)(p) & ((align)-1)) | | ^ | /usr/include/spa-0.2/spa/utils/defs.h:276:42: note: in expansion of macro 'SPA_PTR_ALIGNMENT' | 276 | #define SPA_IS_ALIGNED(p,align) (SPA_PTR_ALIGNMENT(p,align) == 0) | | ^~~~~~~~~~~~~~~~~ | /usr/include/spa-0.2/spa/utils/defs.h:308:13: note: in expansion of macro 'SPA_IS_ALIGNED' | 308 | if (SPA_IS_ALIGNED(p2, align)) { | | ^~~~~~~~~~~~~~ --- spa/include/spa/utils/defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spa/include/spa/utils/defs.h b/spa/include/spa/utils/defs.h index 3444a5aed..43a294f8d 100644 --- a/spa/include/spa/utils/defs.h +++ b/spa/include/spa/utils/defs.h @@ -272,7 +272,7 @@ struct spa_fraction { }) -#define SPA_PTR_ALIGNMENT(p,align) ((intptr_t)(p) & ((align)-1)) +#define SPA_PTR_ALIGNMENT(p,align) ((uintptr_t)(p) & ((align)-1)) #define SPA_IS_ALIGNED(p,align) (SPA_PTR_ALIGNMENT(p,align) == 0) #define SPA_PTR_ALIGN(p,align,type) ((type*)SPA_ROUND_UP_N((intptr_t)(p), (intptr_t)(align)))