Re: [PATCH] ethernet: Delete unnecessary checks before the macro call âdev_kfree_skbâ

From: Scott Branden
Date: Fri Aug 23 2019 - 12:10:13 EST

On 2019-08-23 7:08 a.m., Christophe JAILLET wrote:

in this patch, there is one piece that looked better before. (see below)

Removing the 'if (skb)' is fine, but concatening everything in one statement just to save 2 variables and a few LOC is of no use, IMHO, and the code is less readable.

just my 2c.


diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index d3a0b614dbfa..8b19ddcdafaa 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2515,19 +2515,14 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv)
Âstatic void bcmgenet_fini_dma(struct bcmgenet_priv *priv)
ÂÂÂÂ struct netdev_queue *txq;
-ÂÂÂ struct sk_buff *skb;
-ÂÂÂ struct enet_cb *cb;
ÂÂÂÂ int i;

ÂÂÂÂ bcmgenet_fini_rx_napi(priv);
ÂÂÂÂ bcmgenet_fini_tx_napi(priv);

-ÂÂÂ for (i = 0; i < priv->num_tx_bds; i++) {
-ÂÂÂÂÂÂÂ cb = priv->tx_cbs + i;
-ÂÂÂÂÂÂÂ skb = bcmgenet_free_tx_cb(&priv->pdev->dev, cb);
-ÂÂÂÂÂÂÂ if (skb)
-ÂÂÂÂÂÂÂÂÂÂÂ dev_kfree_skb(skb);
-ÂÂÂ }
+ÂÂÂ for (i = 0; i < priv->num_tx_bds; i++)
+ dev_kfree_skb(bcmgenet_free_tx_cb(&priv->pdev->dev,

ÂÂÂÂ for (i = 0; i < priv->hw_params->tx_queues; i++) {
ÂÂÂÂÂÂÂÂ txq = netdev_get_tx_queue(priv->dev, priv->tx_rings[i].queue);