diff options
author | Linus Lüssing <linus.luessing@web.de> | 2012-09-13 20:40:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-09-19 15:49:53 -0400 |
commit | dbd6b11e15a2f96030da17dbeda943a8a98ee990 (patch) | |
tree | da58d7bcdf790f48555e4e0152ddf3a1df23dee8 | |
parent | 59d86c760fbb855d9a26b9b280d4ff59303f2fc5 (diff) |
batman-adv: make batadv_test_bit() return 0 or 1 only
On some architectures test_bit() can return other values than 0 or 1:
With a generic x86 OpenWrt image in a kvm setup (batadv_)test_bit()
frequently returns -1 for me, leading to batadv_iv_ogm_update_seqnos()
wrongly signaling a protected seqno window.
This patch tries to fix this issue by making batadv_test_bit() return 0
or 1 only.
Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Acked-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/batman-adv/bitarray.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h index a081ce1c0514..cebaae7e148b 100644 --- a/net/batman-adv/bitarray.h +++ b/net/batman-adv/bitarray.h | |||
@@ -20,8 +20,8 @@ | |||
20 | #ifndef _NET_BATMAN_ADV_BITARRAY_H_ | 20 | #ifndef _NET_BATMAN_ADV_BITARRAY_H_ |
21 | #define _NET_BATMAN_ADV_BITARRAY_H_ | 21 | #define _NET_BATMAN_ADV_BITARRAY_H_ |
22 | 22 | ||
23 | /* returns true if the corresponding bit in the given seq_bits indicates true | 23 | /* Returns 1 if the corresponding bit in the given seq_bits indicates true |
24 | * and curr_seqno is within range of last_seqno | 24 | * and curr_seqno is within range of last_seqno. Otherwise returns 0. |
25 | */ | 25 | */ |
26 | static inline int batadv_test_bit(const unsigned long *seq_bits, | 26 | static inline int batadv_test_bit(const unsigned long *seq_bits, |
27 | uint32_t last_seqno, uint32_t curr_seqno) | 27 | uint32_t last_seqno, uint32_t curr_seqno) |
@@ -32,7 +32,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits, | |||
32 | if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE) | 32 | if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE) |
33 | return 0; | 33 | return 0; |
34 | else | 34 | else |
35 | return test_bit(diff, seq_bits); | 35 | return test_bit(diff, seq_bits) != 0; |
36 | } | 36 | } |
37 | 37 | ||
38 | /* turn corresponding bit on, so we can remember that we got the packet */ | 38 | /* turn corresponding bit on, so we can remember that we got the packet */ |