e069fa7056f04cda6c72480a09ad73c53b47719c
[12.09/packages.git] / net / batman-adv / patches / 0001-batman-adv-make-batadv_test_bit-return-0-or-1-only.patch
1 From 716c8c9a8bb7ac1e30e959e50ed74caa7dabe60a Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@web.de>
3 Date: Mon, 3 Sep 2012 22:20:31 +0200
4 Subject: [PATCH] batman-adv: make batadv_test_bit() return 0 or 1 only
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 On some architectures test_bit() can return other values than 0 or 1:
10
11 With a generic x86 OpenWrt image in a kvm setup (batadv_)test_bit()
12 frequently returns -1 for me, leading to batadv_iv_ogm_update_seqnos()
13 wrongly signaling a protected seqno window.
14
15 This patch tries to fix this issue by making batadv_test_bit() return 0
16 or 1 only.
17
18 Signed-off-by: Linus Lüssing <linus.luessing@web.de>
19 Acked-by: Sven Eckelmann <sven@narfation.org>
20 ---
21  bitarray.h |    6 +++---
22  1 files changed, 3 insertions(+), 3 deletions(-)
23
24 diff --git a/bitarray.h b/bitarray.h
25 index a081ce1..cebaae7 100644
26 --- a/bitarray.h
27 +++ b/bitarray.h
28 @@ -20,8 +20,8 @@
29  #ifndef _NET_BATMAN_ADV_BITARRAY_H_
30  #define _NET_BATMAN_ADV_BITARRAY_H_
31  
32 -/* returns true if the corresponding bit in the given seq_bits indicates true
33 - * and curr_seqno is within range of last_seqno
34 +/* Returns 1 if the corresponding bit in the given seq_bits indicates true
35 + * and curr_seqno is within range of last_seqno. Otherwise returns 0.
36   */
37  static inline int batadv_test_bit(const unsigned long *seq_bits,
38                                   uint32_t last_seqno, uint32_t curr_seqno)
39 @@ -32,7 +32,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits,
40         if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE)
41                 return 0;
42         else
43 -               return  test_bit(diff, seq_bits);
44 +               return test_bit(diff, seq_bits) != 0;
45  }
46  
47  /* turn corresponding bit on, so we can remember that we got the packet */
48 -- 
49 1.7.9.1
50