summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-08-14 11:21:54 +0200
committerBenBE <BenBE@geshi.org>2021-10-01 18:36:35 +0200
commit970885edc3553d6dd23a39cd56e1884b550f2d2a (patch)
tree6d24619ce710c80944a7b5c38600c85f0a414526
parentae1816e563b8fd854f7e70a3f9a7ee0911e8a49a (diff)
Linux: improve tryRead macro safety
Add an explicit else clause so a following else branch for a prior if condition does not get mixed up. Also force a trailing semicolon and thereby silence current -Wextra-semi-stmt warnings. Improve readability of the hwloc_bitmap_foreach_begin loop macro.
-rw-r--r--configure.ac1
-rw-r--r--linux/LinuxProcessList.c6
2 files changed, 4 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 2a4880ba..da8d8bd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -668,6 +668,7 @@ AS_VAR_IF(CACHEVAR,yes,
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS
+AX_CHECK_COMPILE_FLAG([-Wextra-semi-stmt], [AM_CFLAGS="$AM_CFLAGS -Wextra-semi-stmt"], , [-Werror=unknown-warning-option]) dnl the autoconf check itself generates -Wextra-semi-stmt
AX_CHECK_COMPILE_FLAG([-Wimplicit-int-conversion], [AM_CFLAGS="$AM_CFLAGS -Wimplicit-int-conversion"], , [-Werror])
AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [AM_CFLAGS="$AM_CFLAGS -Wnull-dereference"], , [-Werror])
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index bd80ae8b..dbbc57d1 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -1609,7 +1609,7 @@ static inline void LinuxProcessList_scanMemoryInfo(ProcessList* this) {
(variable) = parsed_; \
} \
break; \
- }
+ } else (void) 0 /* Require a ";" after the macro use. */
switch (buffer[0]) {
case 'M':
@@ -1785,12 +1785,12 @@ static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) {
if (String_startsWith(buffer, label)) { \
sscanf(buffer + strlen(label), " %*2u %32llu", variable); \
break; \
- }
+ } else (void) 0 /* Require a ";" after the macro use. */
#define tryReadFlag(label, variable, flag) \
if (String_startsWith(buffer, label)) { \
(flag) = sscanf(buffer + strlen(label), " %*2u %32llu", variable); \
break; \
- }
+ } else (void) 0 /* Require a ";" after the macro use. */
switch (buffer[0]) {
case 'c':

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