From 8c1f5c5a6f341fc654808887fcbeec0ba2994f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 27 Oct 2020 21:26:33 +0100 Subject: Enclose macro arguments in parentheses --- Panel.h | 8 ++++---- RichString.h | 6 +++--- linux/IOPriority.h | 2 +- linux/LinuxProcessList.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Panel.h b/Panel.h index 87846075..ec670ab5 100644 --- a/Panel.h +++ b/Panel.h @@ -27,11 +27,11 @@ typedef enum HandlerResult_ { SYNTH_KEY = 0x20, } HandlerResult; -#define EVENT_SET_SELECTED -1 +#define EVENT_SET_SELECTED (-1) -#define EVENT_HEADER_CLICK(x_) (-10000 + x_) -#define EVENT_IS_HEADER_CLICK(ev_) (ev_ >= -10000 && ev_ <= -9000) -#define EVENT_HEADER_CLICK_GET_X(ev_) (ev_ + 10000) +#define EVENT_HEADER_CLICK(x_) (-10000 + (x_)) +#define EVENT_IS_HEADER_CLICK(ev_) ((ev_) >= -10000 && (ev_) <= -9000) +#define EVENT_HEADER_CLICK_GET_X(ev_) ((ev_) + 10000) typedef HandlerResult(*Panel_EventHandler)(Panel*, int); diff --git a/RichString.h b/RichString.h index 2e35b827..1320c938 100644 --- a/RichString.h +++ b/RichString.h @@ -15,13 +15,13 @@ in the source distribution for its full text. #define RichString_size(this) ((this)->chlen) #define RichString_sizeVal(this) ((this).chlen) -#define RichString_begin(this) RichString (this); memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr; -#define RichString_beginAllocated(this) memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr; +#define RichString_begin(this) RichString (this); memset(&(this), 0, sizeof(RichString)); (this).chptr = (this).chstr; +#define RichString_beginAllocated(this) memset(&(this), 0, sizeof(RichString)); (this).chptr = (this).chstr; #define RichString_end(this) RichString_prune(&(this)); #ifdef HAVE_LIBNCURSESW #define RichString_printVal(this, y, x) mvadd_wchstr(y, x, (this).chptr) -#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, (this).chptr + off, n) +#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, (this).chptr + (off), n) #define RichString_getCharVal(this, i) ((this).chptr[i].chars[0] & 255) #define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)] = (CharType) { .chars = { ch, 0 } }; } while(0) #define CharType cchar_t diff --git a/linux/IOPriority.h b/linux/IOPriority.h index e60eb9ba..551a7d50 100644 --- a/linux/IOPriority.h +++ b/linux/IOPriority.h @@ -28,7 +28,7 @@ enum { typedef int IOPriority; -#define IOPriority_tuple(class_, data_) (((class_) << IOPRIO_CLASS_SHIFT) | data_) +#define IOPriority_tuple(class_, data_) (((class_) << IOPRIO_CLASS_SHIFT) | (data_)) #define IOPriority_error 0xffffffff diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 10c9d982..2530b2bb 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -1161,7 +1161,7 @@ static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) { char buffer[128]; while (fgets(buffer, 128, file)) { #define tryRead(label, variable) do { if (String_startsWith(buffer, label) && sscanf(buffer + strlen(label), " %*2u %32llu", variable)) { break; } } while(0) - #define tryReadFlag(label, variable, flag) do { if (String_startsWith(buffer, label) && sscanf(buffer + strlen(label), " %*2u %32llu", variable)) { flag = 1; break; } else { flag = 0; } } while(0) + #define tryReadFlag(label, variable, flag) do { if (String_startsWith(buffer, label) && sscanf(buffer + strlen(label), " %*2u %32llu", variable)) { (flag) = 1; break; } else { (flag) = 0; } } while(0) switch (buffer[0]) { case 'c': tryRead("c_max", &lpl->zfs.max); @@ -1248,7 +1248,7 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) { // Since we do a subtraction (usertime - guest) and cputime64_to_clock_t() // used in /proc/stat rounds down numbers, it can lead to a case where the // integer overflow. - #define WRAP_SUBTRACT(a,b) (a > b) ? a - b : 0 + #define WRAP_SUBTRACT(a,b) (((a) > (b)) ? (a) - (b) : 0) cpuData->userPeriod = WRAP_SUBTRACT(usertime, cpuData->userTime); cpuData->nicePeriod = WRAP_SUBTRACT(nicetime, cpuData->niceTime); cpuData->systemPeriod = WRAP_SUBTRACT(systemtime, cpuData->systemTime); -- cgit v1.2.3