diff mbox series

[v2] net: ethernet: ag71xx: Remove dead code

Message ID 20240911135828.378317-1-usama.anjum@collabora.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: ethernet: ag71xx: Remove dead code | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 31 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-09-13--03-00 (tests: 764)

Commit Message

Muhammad Usama Anjum Sept. 11, 2024, 1:58 p.m. UTC
The err variable isn't being used anywhere other than getting
initialized to 0 and then it is being checked in if condition. The
condition can never be true. Remove the err and deadcode.

Move the rx_dropped counter above when skb isn't found.

Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
Changes since v1:
- Move the rx_dropped counter above when skb isn't found.
---
 drivers/net/ethernet/atheros/ag71xx.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

Andrew Lunn Sept. 11, 2024, 2:24 p.m. UTC | #1
On Wed, Sep 11, 2024 at 06:58:27PM +0500, Muhammad Usama Anjum wrote:
> The err variable isn't being used anywhere other than getting
> initialized to 0 and then it is being checked in if condition. The
> condition can never be true. Remove the err and deadcode.
> 
> Move the rx_dropped counter above when skb isn't found.
> 
> Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Vadim Fedorenko Sept. 11, 2024, 3:47 p.m. UTC | #2
On 11/09/2024 14:58, Muhammad Usama Anjum wrote:
> The err variable isn't being used anywhere other than getting
> initialized to 0 and then it is being checked in if condition. The
> condition can never be true. Remove the err and deadcode.
> 
> Move the rx_dropped counter above when skb isn't found.
> 
> Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
> Changes since v1:
> - Move the rx_dropped counter above when skb isn't found.
> ---
>   drivers/net/ethernet/atheros/ag71xx.c | 13 ++++---------
>   1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
> index db2a8ade62055..2effceeb191db 100644
> --- a/drivers/net/ethernet/atheros/ag71xx.c
> +++ b/drivers/net/ethernet/atheros/ag71xx.c
> @@ -1619,7 +1619,6 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
>   		unsigned int i = ring->curr & ring_mask;
>   		struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
>   		int pktlen;
> -		int err = 0;
>   
>   		if (ag71xx_desc_empty(desc))
>   			break;
> @@ -1643,20 +1642,16 @@ static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
>   		skb = napi_build_skb(ring->buf[i].rx.rx_buf, ag71xx_buffer_size(ag));
>   		if (!skb) {
>   			skb_free_frag(ring->buf[i].rx.rx_buf);
> +			ndev->stats.rx_dropped++;
>   			goto next;
>   		}
>   
>   		skb_reserve(skb, offset);
>   		skb_put(skb, pktlen);
>   
> -		if (err) {
> -			ndev->stats.rx_dropped++;
> -			kfree_skb(skb);
> -		} else {
> -			skb->dev = ndev;
> -			skb->ip_summed = CHECKSUM_NONE;
> -			list_add_tail(&skb->list, &rx_list);
> -		}
> +		skb->dev = ndev;
> +		skb->ip_summed = CHECKSUM_NONE;
> +		list_add_tail(&skb->list, &rx_list);
>   
>   next:
>   		ring->buf[i].rx.rx_buf = NULL;


Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Oleksij Rempel Sept. 11, 2024, 6:20 p.m. UTC | #3
On Wed, Sep 11, 2024 at 06:58:27PM +0500, Muhammad Usama Anjum wrote:
> The err variable isn't being used anywhere other than getting
> initialized to 0 and then it is being checked in if condition. The
> condition can never be true. Remove the err and deadcode.
> 
> Move the rx_dropped counter above when skb isn't found.
> 
> Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
 
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>

Thank you!

Regards,
Oleksij
Eric Dumazet Sept. 12, 2024, 3:56 p.m. UTC | #4
On Wed, Sep 11, 2024 at 8:20 PM Oleksij Rempel <o.rempel@pengutronix.de> wrote:
>
> On Wed, Sep 11, 2024 at 06:58:27PM +0500, Muhammad Usama Anjum wrote:
> > The err variable isn't being used anywhere other than getting
> > initialized to 0 and then it is being checked in if condition. The
> > condition can never be true. Remove the err and deadcode.
> >
> > Move the rx_dropped counter above when skb isn't found.
> >
> > Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
> > Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
>
> Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
>
> Thank you!
>
> Regards,
> Oleksij

I do not see any credits given to  Qianqiang Liu, who is desperate to get his
first linux patch...

https://lore.kernel.org/netdev/20240910152254.21238-1-qianqiang.liu@163.com/
Qianqiang Liu Sept. 12, 2024, 4:28 p.m. UTC | #5
Hi Eric,

> I do not see any credits given to  Qianqiang Liu, who is desperate to get his
> first linux patch...
> 
> https://lore.kernel.org/netdev/20240910152254.21238-1-qianqiang.liu@163.com/

Yes, you are right! I'm a kernel newbie.
But Linux is a FOSS software, and anyone can contribute, right?
Actually, I have two patches that were merged into the linux-next branch:

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=93497752dfed196b41d2804503e80b9a04318adb
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=cd0920ebab6bce93ac5054d621c0633f6a4d640b
Jakub Kicinski Sept. 13, 2024, 12:42 a.m. UTC | #6
On Thu, 12 Sep 2024 17:56:11 +0200 Eric Dumazet wrote:
> On Wed, Sep 11, 2024 at 8:20 PM Oleksij Rempel <o.rempel@pengutronix.de> wrote:
> > On Wed, Sep 11, 2024 at 06:58:27PM +0500, Muhammad Usama Anjum wrote:  
> > > The err variable isn't being used anywhere other than getting
> > > initialized to 0 and then it is being checked in if condition. The
> > > condition can never be true. Remove the err and deadcode.
> > >
> > > Move the rx_dropped counter above when skb isn't found.
> > >
> > > Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
> > > Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>  
> >
> > Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
> 
> I do not see any credits given to  Qianqiang Liu, who is desperate to get his
> first linux patch...
> 
> https://lore.kernel.org/netdev/20240910152254.21238-1-qianqiang.liu@163.com/

Right, odd, is there a reason you took over from Qianqiang Liu?
Otherwise I'd prefer if they could send the next version.
Last thing we need is arguments about ownership of trivial
patches.

This v2 has an unnecessary Fixes tag, this is not a fix.
Jakub Kicinski Sept. 13, 2024, 3:27 a.m. UTC | #7
On Thu, 12 Sep 2024 17:42:22 -0700 Jakub Kicinski wrote:
> On Thu, 12 Sep 2024 17:56:11 +0200 Eric Dumazet wrote:
> > I do not see any credits given to  Qianqiang Liu, who is desperate to get his
> > first linux patch...
> > 
> > https://lore.kernel.org/netdev/20240910152254.21238-1-qianqiang.liu@163.com/  
> 
> Right, odd, is there a reason you took over from Qianqiang Liu?
> Otherwise I'd prefer if they could send the next version.
> Last thing we need is arguments about ownership of trivial
> patches.
> 
> This v2 has an unnecessary Fixes tag, this is not a fix.

Oh, I guess it may be a v2 of your own change:

https://lore.kernel.org/all/20240911105924.4028423-1-usama.anjum@collabora.com/

Are you both using the same tool? 5 year old code and suddenly we get
the same fix two times.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
index db2a8ade62055..2effceeb191db 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -1619,7 +1619,6 @@  static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
 		unsigned int i = ring->curr & ring_mask;
 		struct ag71xx_desc *desc = ag71xx_ring_desc(ring, i);
 		int pktlen;
-		int err = 0;
 
 		if (ag71xx_desc_empty(desc))
 			break;
@@ -1643,20 +1642,16 @@  static int ag71xx_rx_packets(struct ag71xx *ag, int limit)
 		skb = napi_build_skb(ring->buf[i].rx.rx_buf, ag71xx_buffer_size(ag));
 		if (!skb) {
 			skb_free_frag(ring->buf[i].rx.rx_buf);
+			ndev->stats.rx_dropped++;
 			goto next;
 		}
 
 		skb_reserve(skb, offset);
 		skb_put(skb, pktlen);
 
-		if (err) {
-			ndev->stats.rx_dropped++;
-			kfree_skb(skb);
-		} else {
-			skb->dev = ndev;
-			skb->ip_summed = CHECKSUM_NONE;
-			list_add_tail(&skb->list, &rx_list);
-		}
+		skb->dev = ndev;
+		skb->ip_summed = CHECKSUM_NONE;
+		list_add_tail(&skb->list, &rx_list);
 
 next:
 		ring->buf[i].rx.rx_buf = NULL;