batman-adv: Remove extra check in batadv_bit_get_packet
authorSven Eckelmann <sven@narfation.org>
Mon, 20 Aug 2012 08:26:47 +0000 (10:26 +0200)
committerAntonio Quartulli <ordex@autistici.org>
Mon, 29 Oct 2012 08:42:34 +0000 (09:42 +0100)
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>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
net/batman-adv/bitarray.c

index aea174cdbfbd4689b6ee989dfa9ab710a7f5cc11..5453b17d8df20249c6647bcc5c2485edfec4c1e5 100644 (file)
@@ -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);
-
-               return 1;
-       }
+       bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
+       if (set_mark)
+               batadv_set_bit(seq_bits, 0);
 
-       /* never reached */
-       return 0;
+       return 1;
 }