Skip to contentSkip to conversation

batctl: Avoid overoptimization of signal related check

PATCH New Sven Eckelmann 1 participant 1 message May 19, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batctl: Avoid overoptimization of signal related check

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.

---
 ping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ping.c +1 -1
index c52ad13..bc5184d 100644
@@ -44,7 +44,7 @@
 #include "debugfs.h"
 
 
-char is_aborted = 0;
+static volatile sig_atomic_t is_aborted = 0;
 
 
 static void ping_usage(void)
Signature · 1 line
2.0.0.rc2