[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZJmHRrd/erRQXZgD@corigine.com>
Date: Mon, 26 Jun 2023 14:40:38 +0200
From: Simon Horman <simon.horman@...igine.com>
To: You Kangren <youkangren@...o.com>
Cc: Kalle Valo <kvalo@...nel.org>, Dongliang Mu <dzm91@...t.edu.cn>,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
"open list:RAYLINK/WEBGEAR 802.11 WIRELESS LAN DRIVER"
<linux-wireless@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>,
opensource.kernel@...o.com
Subject: Re: [PATCH] wifi: ray_cs: Remove invalid conditional statements
On Mon, Jun 26, 2023 at 06:27:50PM +0800, You Kangren wrote:
> Remove invalid conditional statements to make the code clean
>
> Signed-off-by: You Kangren <youkangren@...o.com>
> ---
> drivers/net/wireless/legacy/ray_cs.c | 13 -------------
> 1 file changed, 13 deletions(-)
>
> diff --git a/drivers/net/wireless/legacy/ray_cs.c b/drivers/net/wireless/legacy/ray_cs.c
> index 96f34d90f601..0022038b0758 100644
> --- a/drivers/net/wireless/legacy/ray_cs.c
> +++ b/drivers/net/wireless/legacy/ray_cs.c
> @@ -2116,7 +2116,6 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
> #endif
>
> if (!sniffer) {
> - if (translate) {
> /* TBD length needs fixing for translated header */
> if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
> rx_len >
> @@ -2126,18 +2125,6 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
> "ray_cs invalid packet length %d received\n",
> rx_len);
> return;
> - }
Hi You Kangren,
Some minor nits from my side:
1. The indentation of the code is now wrong,
it should be adjusted one tab-stop to the left.
2. The two remaining conditions can be collapsed,
which leads to a further reduction in indentation.
3. Also, the indentation of the "TBD" comment was wrong before this patch,
and is still wrong. So we can probably fix that while we are here.
I suggest folding in something like this (completely untested!).
diff --git a/drivers/net/wireless/legacy/ray_cs.c b/drivers/net/wireless/legacy/ray_cs.c
index f0bc7a06a257..f339927f1f56 100644
--- a/drivers/net/wireless/legacy/ray_cs.c
+++ b/drivers/net/wireless/legacy/ray_cs.c
@@ -2116,17 +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) {
-/* 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;
- }
+ /* 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 */
Powered by blists - more mailing lists