[B.A.T.M.A.N.] [PATCH 3/4] batctl: ping: Use sig_atomic_t variable to stop ping

Sven Eckelmann
2017-01-22T12:07:48Z

The variable used in the signal handlers of ping is currently only a
char. It is shared with the main routine which checks if the ping should be
stopped or not. But the standard defines that such a variable must be
volatile sig_atomic_t or a lock-free atomic object.

The volatile definition avoids that the compiler must not assume that this
object can be cached. sig_atomic_t will make sure that this object is
atomically accessible in asynchronous interrupts. Not using these types
could result in an "unstoppable" ping.

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

diff --git a/ping.c b/ping.c
index 4fef663..7e5c6fc 100644
--- a/ping.c
+++ b/ping.c
@@ -45,7 +45,7 @@
#include "icmp_helper.h"

-char is_aborted = 0;
+static volatile sig_atomic_t is_aborted = 0;

static void ping_usage(void)
--
2.11.0