From patchwork Wed Dec 1 19:59:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 602 Return-Path: Received: from mail.gmx.net (mailout-de.gmx.net [213.165.64.22]) by open-mesh.org (Postfix) with SMTP id 68A81154623 for ; Wed, 1 Dec 2010 20:58:23 +0100 (CET) Received: (qmail invoked by alias); 01 Dec 2010 19:58:22 -0000 Received: from i59F6DF4D.versanet.de (EHLO sven-desktop.lazhur.ath.cx) [89.246.223.77] by mail.gmx.net (mp070) with SMTP; 01 Dec 2010 20:58:22 +0100 X-Authenticated: #15668376 X-Provags-ID: V01U2FsdGVkX1/SYdxi1ZTSqQzHX3iW6p/c0QeMdg3fT8A+fjFC+K YxA20T/Bwi/D3e From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 1 Dec 2010 20:59:07 +0100 Message-Id: <1291233547-9437-1-git-send-email-sven.eckelmann@gmx.de> X-Mailer: git-send-email 1.7.2.3 X-Y-GMX-Trusted: 0 Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: Use kernel facilities for bit operations X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Dec 2010 19:58:23 -0000 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 Signed-off-by: Sven Eckelmann --- 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. */