Skip to content

Commit

Permalink
batman-adv: make batadv_test_bit() return 0 or 1 only
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Sven Eckelmann <[email protected]>
Signed-off-by: Antonio Quartulli <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
T-X authored and davem330 committed Sep 19, 2012
1 parent 59d86c7 commit dbd6b11
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/batman-adv/bitarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#ifndef _NET_BATMAN_ADV_BITARRAY_H_
#define _NET_BATMAN_ADV_BITARRAY_H_

/* returns true if the corresponding bit in the given seq_bits indicates true
* and curr_seqno is within range of last_seqno
/* Returns 1 if the corresponding bit in the given seq_bits indicates true
* and curr_seqno is within range of last_seqno. Otherwise returns 0.
*/
static inline int batadv_test_bit(const unsigned long *seq_bits,
uint32_t last_seqno, uint32_t curr_seqno)
Expand All @@ -32,7 +32,7 @@ static inline int batadv_test_bit(const unsigned long *seq_bits,
if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE)
return 0;
else
return test_bit(diff, seq_bits);
return test_bit(diff, seq_bits) != 0;
}

/* turn corresponding bit on, so we can remember that we got the packet */
Expand Down

0 comments on commit dbd6b11

Please sign in to comment.