[B.A.T.M.A.N.] [PATCH] batctl: Avoid overoptimization of signal related check

Sven Eckelmann sven at narfation.org
Mon May 19 13:50:08 CEST 2014

According to C99, it is not safe to use a simple char for checks because the
compiler may optimizes it away when it only gets modified in a signal handler.
It is also undefined when the signal is modifying an object with static
storage duration not from type volatile sig_atomic_t.

Signed-off-by: Sven Eckelmann <sven at narfation.org>
 ping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ping.c b/ping.c
index c52ad13..bc5184d 100644
--- a/ping.c
+++ b/ping.c
@@ -44,7 +44,7 @@
 #include "debugfs.h"
-char is_aborted = 0;
+static volatile sig_atomic_t is_aborted = 0;
 static void ping_usage(void)

More information about the B.A.T.M.A.N mailing list