public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Remove extra check in batadv_bit_get_packet
@ 2012-08-20  8:26 Sven Eckelmann
  2012-08-20  8:26 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Check return value of try_module_get Sven Eckelmann
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Sven Eckelmann @ 2012-08-20  8:26 UTC (permalink / raw)
  To: b.a.t.m.a.n

batadv_bit_get_packet checks for all common situations before it decides that
the new received packet indicates that the host was restarted. This extra
condition check at the end of the function is not necessary because this
condition is always true.

This patch addresses Coverity #712296: Logically dead code

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 bitarray.c |   23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/bitarray.c b/bitarray.c
index aea174c..5453b17 100644
--- a/bitarray.c
+++ b/bitarray.c
@@ -79,20 +79,17 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
 	 * or the old packet got delayed somewhere in the network. The
 	 * packet should be dropped without calling this function if the
 	 * seqno window is protected.
+	 *
+	 * seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE
+	 * or
+	 * seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE
 	 */
-	if (seq_num_diff <= -BATADV_TQ_LOCAL_WINDOW_SIZE ||
-	    seq_num_diff >= BATADV_EXPECTED_SEQNO_RANGE) {
+	batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
+		   "Other host probably restarted!\n");
 
-		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
-			   "Other host probably restarted!\n");
+	bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
+	if (set_mark)
+		batadv_set_bit(seq_bits, 0);
 
-		bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
-		if (set_mark)
-			batadv_set_bit(seq_bits, 0);
-
-		return 1;
-	}
-
-	/* never reached */
-	return 0;
+	return 1;
 }
-- 
1.7.10.4


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

end of thread, other threads:[~2012-08-24 22:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-20  8:26 [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Remove extra check in batadv_bit_get_packet Sven Eckelmann
2012-08-20  8:26 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Check return value of try_module_get Sven Eckelmann
2012-08-20 21:37   ` [B.A.T.M.A.N.] [PATCHv3 " Sven Eckelmann
2012-08-24 22:08     ` Marek Lindner
2012-08-20  8:26 ` [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Only increase refcounter once for alternate router Sven Eckelmann
2012-08-24 22:19   ` Marek Lindner
2012-08-20 20:54 ` [B.A.T.M.A.N.] [PATCHv2 2/3] batman-adv: Check return value of try_module_get Sven Eckelmann
2012-08-24 21:59 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Remove extra check in batadv_bit_get_packet Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox