From patchwork Mon Sep 3 20:20:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 2287 Return-Path: Received: from mout.web.de (mout.web.de [212.227.17.12]) by open-mesh.org (Postfix) with ESMTP id 13B39600A86 for ; Mon, 3 Sep 2012 22:19:58 +0200 (CEST) Received: from localhost ([94.75.220.253]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0LdEsP-1TqWa440Jd-00i4vj; Mon, 03 Sep 2012 22:19:58 +0200 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 3 Sep 2012 22:20:31 +0200 Message-Id: <1346703631-17948-1-git-send-email-linus.luessing@web.de> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-Provags-ID: V02:K0:aH+pLh+2BM5gu5NeXf6hXY/O/XCbEnGUKSBUCLNP7R8 0G+xmOgoN4S2Bo9jHJYnGPy3l/rHXxz8hrQJyo7oZKF4Is0k6I 8zxaIwi511Uv84VR8RxGWn7QGg0ZNL5bePzypTWAFHdXW36Uh7 4gaav/uCnuilPd4BnAUAvRLjrQ9tByeMLo2Xc1mjs4Ywl3bAo/ FomVHD535+EvT9kypxjdw== Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: make batadv_test_bit() return 0 or 1 only X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 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: Mon, 03 Sep 2012 20:19:59 -0000 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 Acked-by: Sven Eckelmann --- bitarray.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bitarray.h b/bitarray.h index a081ce1..cebaae7 100644 --- a/bitarray.h +++ b/bitarray.h @@ -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) @@ -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 */