lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230628021647.28655-1-youkangren@vivo.com>
Date:   Wed, 28 Jun 2023 10:16:46 +0800
From:   You Kangren <youkangren@...o.com>
To:     Kalle Valo <kvalo@...nel.org>, Dongliang Mu <dzm91@...t.edu.cn>,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        You Kangren <youkangren@...o.com>,
        Simon Horman <simon.horman@...igine.com>,
        linux-wireless@...r.kernel.org (open list:RAYLINK/WEBGEAR 802.11
        WIRELESS LAN DRIVER), linux-kernel@...r.kernel.org (open list)
Cc:     opensource.kernel@...o.com
Subject: [PATCH v3] Remove unnecessary conditional statements

A warning is found at compiling time that the if and else branches 
in the rx_data function have no effect, we check the code and 
find the contents of both branches are the same, so we merge
the contents of both branches into one.

Signed-off-by: You Kangren <youkangren@...o.com>
---
 drivers/net/wireless/legacy/ray_cs.c | 30 ++++++----------------------
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/legacy/ray_cs.c b/drivers/net/wireless/legacy/ray_cs.c
index 8ace797ce951..dc2feb88453e 100644
--- a/drivers/net/wireless/legacy/ray_cs.c
+++ b/drivers/net/wireless/legacy/ray_cs.c
@@ -2116,30 +2116,12 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
 	u_char linksrcaddr[ETH_ALEN];	/* Other end of the wireless link */
 #endif
 
-	if (!sniffer) {
-		if (translate) {
-/* TBD length needs fixing for translated header */
-			if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
-			    rx_len >
-			    (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
-			     FCS_LEN)) {
-				pr_debug(
-				      "ray_cs invalid packet length %d received\n",
-				      rx_len);
-				return;
-			}
-		} else { /* encapsulated ethernet */
-
-			if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
-			    rx_len >
-			    (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
-			     FCS_LEN)) {
-				pr_debug(
-				      "ray_cs invalid packet length %d received\n",
-				      rx_len);
-				return;
-			}
-		}
+	/* TBD length needs fixing for translated header */
+	if (!sniffer && (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
+			 rx_len > (dev->mtu + RX_MAC_HEADER_LENGTH +
+			 ETH_HLEN + FCS_LEN))) {
+		pr_debug("ray_cs invalid packet length %d received\n", rx_len);
+		return;
 	}
 	pr_debug("ray_cs rx_data packet\n");
 	/* If fragmented packet, verify sizes of fragments add up */
-- 
2.39.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ