diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-19 08:29:36 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-19 08:29:36 +0200 |
| commit | 4cf0dd3b0bd2aa2c63d72490ccf3c57d1b16c664 (patch) | |
| tree | b1d3da61e4403c844304047e7925dcfe60dfd316 | |
| parent | b7a9aa7200cb8e935f57a772ea8487687980f787 (diff) | |
fix: parenthesize arithmetic macros (task 474)
| -rw-r--r-- | ioriot/src/macros.h | 6 |
1 files 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__) |
