From patchwork Sun Oct 28 11:17:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 194679 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B602B2C0086 for ; Sun, 28 Oct 2012 22:18:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752125Ab2J1LS3 (ORCPT ); Sun, 28 Oct 2012 07:18:29 -0400 Received: from latitanza.investici.org ([82.94.249.234]:55827 "EHLO latitanza.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751927Ab2J1LS2 (ORCPT ); Sun, 28 Oct 2012 07:18:28 -0400 Received: from [82.94.249.234] (latitanza [82.94.249.234]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id D1BD09817B; Sun, 28 Oct 2012 11:18:22 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 latitanza.investici.org D1BD09817B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1351423107; bh=SmL2BYkE916NVtbAOf7H7eBDsKY0WFAt0wDQelh82Lc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=KldylAxqP+1OuMtkhK9mVpVzQnNp6a7jXudpKTtwkP1F6IdGGct2aPqKcX2MhNuF9 0RMwD0JucXj6fjk4gpQb6LRtTtP/GFBDZqsdZ64ejlDnPJ1XyA7JTn0OhyiQES6/Oz 4mz/Jhhh1E1jnJoGCIIulmA3OHbFQD9nSlw3C6Eo= From: Antonio Quartulli To: davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Sven Eckelmann , Antonio Quartulli Subject: [PATCH 07/16] batman-adv: Remove extra check in batadv_bit_get_packet Date: Sun, 28 Oct 2012 12:17:08 +0100 Message-Id: <1351423037-5292-8-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1351423037-5292-1-git-send-email-ordex@autistici.org> References: <1351423037-5292-1-git-send-email-ordex@autistici.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sven Eckelmann 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 Signed-off-by: Antonio Quartulli --- net/batman-adv/bitarray.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/net/batman-adv/bitarray.c b/net/batman-adv/bitarray.c index aea174c..5453b17 100644 --- a/net/batman-adv/bitarray.c +++ b/net/batman-adv/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; }