From 4cf0dd3b0bd2aa2c63d72490ccf3c57d1b16c664 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 19 Mar 2026 08:29:36 +0200 Subject: fix: parenthesize arithmetic macros (task 474) --- ioriot/src/macros.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ioriot/src/macros.h b/ioriot/src/macros.h index 45e5a10..7a13939 100644 --- a/ioriot/src/macros.h +++ b/ioriot/src/macros.h @@ -24,9 +24,9 @@ #define Eq(str1,str2) strcmp(str1,str2) == 0 // Number helpers -#define Abs(num) num >= 0 ? num : -num +#define Abs(num) ((num) >= 0 ? (num) : -(num)) #define Readhex(str) strtol(str, NULL, 16) -#define Perc(a, b) a > b ? b/(a/100.) : a/(b/100.) +#define Perc(a, b) ((a) > (b) ? ((b) / ((a) / 100.)) : ((a) / ((b) / 100.))) // Bitwise helpers #define Has(flags, what) (flags & (what)) == (what) @@ -38,7 +38,7 @@ #define Calloc(count,what) \ notnull(calloc(count,sizeof(what)),__FILE__,__LINE__,count) #define Mset(where,value,count,what) \ - memset(where,value,count*sizeof(what)) + memset((where), (value), ((count) * sizeof(what))) // Open helpers #define Fopen(path, mode) fnotnull(fopen(path, mode), path, __FILE__, __LINE__) -- cgit v1.2.3