All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: Use kernel facilities for bit operations
@ 2010-12-01 19:59 Sven Eckelmann
  2010-12-12 19:29 ` Marek Lindner
  0 siblings, 1 reply; 11+ messages in thread
From: Sven Eckelmann @ 2010-12-01 19:59 UTC (permalink / raw)
  To: b.a.t.m.a.n

set_bit and test_bit provide an efficient way to set and test bits of an
unsigned long.

This also fixes the problem that a very old ogm got not recorded as
received due to the missing constant definition "1" as unsigned long
inside the bit_mark operation - also known as "1UL".

Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/bitarray.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/batman-adv/bitarray.c b/batman-adv/bitarray.c
index 814274f..14606fc 100644
--- a/batman-adv/bitarray.c
+++ b/batman-adv/bitarray.c
@@ -40,7 +40,7 @@ uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno,
 		/* which position in the selected word */
 		word_offset = (last_seqno - curr_seqno) % WORD_BIT_SIZE;
 
-		if (seq_bits[word_num] & 1 << word_offset)
+		if (test_bit(word_offset, &seq_bits[word_num]))
 			return 1;
 		else
 			return 0;
@@ -61,7 +61,7 @@ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n)
 	/* which position in the selected word */
 	word_offset = n % WORD_BIT_SIZE;
 
-	seq_bits[word_num] |= 1 << word_offset;	/* turn the position on */
+	set_bit(word_offset, &seq_bits[word_num]);	/* turn the position on */
 }
 
 /* shift the packet array by n places. */
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-12-12 21:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-01 19:59 [B.A.T.M.A.N.] [PATCH] batman-adv: Use kernel facilities for bit operations Sven Eckelmann
2010-12-12 19:29 ` Marek Lindner
2010-12-12 20:33   ` Marek Lindner
2010-12-12 20:43     ` Sven Eckelmann
2010-12-12 20:46       ` [B.A.T.M.A.N.] [PATCHv3 1/2] batman-adv: Remove line over 80 characters Sven Eckelmann
2010-12-12 21:57         ` Marek Lindner
2010-12-12 20:46       ` [B.A.T.M.A.N.] [PATCHv3 2/2] batman-adv: Remove TYPE_OF_WORD define Sven Eckelmann
2010-12-12 21:58         ` Marek Lindner
2010-12-12 20:36   ` [B.A.T.M.A.N.] [PATCH] batman-adv: Use kernel facilities for bit operations Sven Eckelmann
2010-12-12 20:39     ` [B.A.T.M.A.N.] [PATCHv2 1/2] " Sven Eckelmann
2010-12-12 20:39     ` [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: Remove TYPE_OF_WORD define Sven Eckelmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.