summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-10-27 21:26:33 +0100
committercgzones <cgzones@googlemail.com>2020-10-28 19:57:10 +0100
commit8c1f5c5a6f341fc654808887fcbeec0ba2994f95 (patch)
tree1c32a6015a4dea748df8ed1b8f6b67fdb734f03f
parent61bae4c9d27f23b3ebda461a922ae76e63e0a9c2 (diff)
Enclose macro arguments in parentheses
-rw-r--r--Panel.h8
-rw-r--r--RichString.h6
-rw-r--r--linux/IOPriority.h2
-rw-r--r--linux/LinuxProcessList.c4
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);

© 2014-2024 Faster IT GmbH | imprint | privacy policy