From patchwork Sun Dec 12 20:39:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 619 Return-Path: Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 844991545D2 for ; Sun, 12 Dec 2010 21:45:44 +0100 (CET) Received: from sven-desktop.lazhur.ath.cx (unknown [88.130.164.197]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id DDD8294023; Sun, 12 Dec 2010 21:39:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=narfation.org; s=mail; t=1292186365; bh=bDbVzEp+ka3FupX3Ih6l9/vomyc1e9kU2dIUrdhAkak=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=OQpTvwGxj5hs/nO86FyAysdaneXWHF+bBVrJ8iS7LRvof1ot/hUO+AA906cYl/7/W st/nIzQKyxZI0cb4WjlCFIPw5ytlsK4Df3rdzEsoUaSsZS+Jsr87D581gOYv06c+C3 LsopyU2kVXD52tW31nxnCBg2aBCP+J1TOosaz6m4= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 12 Dec 2010 21:39:11 +0100 Message-Id: <1292186352-24624-1-git-send-email-sven@narfation.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <201012122136.48156.sven@narfation.org> References: <201012122136.48156.sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCHv2 1/2] 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: Sun, 12 Dec 2010 20:45:44 -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..5dad5e8 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. */