8139cp: remove a won't occurred BUG_ON
Subsystems (2)
PATCH 1/1 8139cp: remove a won't occurred BUG_ON
when variable i go to the BUG_ON the value is equal to the CP_NUM_STATS, so the BUG_ON won't occur, so remove it
--- drivers/net/ethernet/realtek/8139cp.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/realtek/8139cp.c +0 -1
@@ -1585,7 +1585,6 @@ static void cp_get_ethtool_stats (struct net_device *dev, tmp_stats[i++] =le16_to_cpu (nic_stats->tx_abort); tmp_stats[i++] =le16_to_cpu (nic_stats->tx_underrun); tmp_stats[i++] = cp->cp_stats.rx_frags; -BUG_ON (i !=CP_NUM_STATS );dma_free_coherent (&cp->pdev->dev,sizeof (*nic_stats), nic_stats, dma); }
Signature · 1 line
1.7.12
Quoted 2 lines · Wang Weidong
when variable i go to the
BUG_ONthe value is equal to theCP_NUM_STATS, so theBUG_ONwon't occur, so remove it
We hope that every BUG_ON() does not occur, but that doesn't mean they should be removed. This check is meant to catch mistakes when adding new statistics.
Ben.
Quoted 17 lines
Signed-off-by Wang Weidong <[email protected]>--- drivers/net/ethernet/realtek/8139cp.c | 1 - 1 file changed, 1 deletion(-)drivers/net/ethernet/realtek/8139cp.c +0
-1@@ -1585,7 +1585,6 @@ static void cp_get_ethtool_stats (struct net_device *dev, tmp_stats[i++] =le16_to_cpu (nic_stats->tx_abort); tmp_stats[i++] =le16_to_cpu (nic_stats->tx_underrun); tmp_stats[i++] = cp->cp_stats.rx_frags; -BUG_ON (i !=CP_NUM_STATS );dma_free_coherent (&cp->pdev->dev,sizeof (*nic_stats), nic_stats, dma); }
Signature · 2 lines
Ben Hutchings If the facts do not conform to your theory, they must be disposed of.
Quoted 10 lines · Ben Hutchings
Quoted 2 lines · Wang Weidong
when variable i go to the
BUG_ONthe value is equal to theCP_NUM_STATS, so theBUG_ONwon't occur, so remove itWe hope that every
BUG_ON()does not occur, but that doesn't mean they should be removed. This check is meant to catch mistakes when adding new statistics.Ben.
Hi, Ben.
Yeah, but I think If someone would add new statistics, he should take into account it instead the BUG_ON helper.
And that, I found some other drivers' get_ethtool_stats no have BUG_ON. Should we add the BUG_ON into them?
Regards,
Wang
Quoted 18 lines
Quoted 17 lines
Signed-off-by Wang Weidong <[email protected]>--- drivers/net/ethernet/realtek/8139cp.c | 1 - 1 file changed, 1 deletion(-)drivers/net/ethernet/realtek/8139cp.c +0
-1@@ -1585,7 +1585,6 @@ static void cp_get_ethtool_stats (struct net_device *dev, tmp_stats[i++] =le16_to_cpu (nic_stats->tx_abort); tmp_stats[i++] =le16_to_cpu (nic_stats->tx_underrun); tmp_stats[i++] = cp->cp_stats.rx_frags; -BUG_ON (i !=CP_NUM_STATS );dma_free_coherent (&cp->pdev->dev,sizeof (*nic_stats), nic_stats, dma); }
Quoted 11 lines · Wang Weidong
Quoted 10 lines · Ben Hutchings
Quoted 2 lines · Wang Weidong
when variable i go to the
BUG_ONthe value is equal to theCP_NUM_STATS, so theBUG_ONwon't occur, so remove itWe hope that every
BUG_ON()does not occur, but that doesn't mean they should be removed. This check is meant to catch mistakes when adding new statistics.Ben.
Quoted 7 lines
Hi, Ben.
Yeah, but I think If someone would add new statistics, he should take into account it instead the
BUG_ONhelper.And that, I found some other drivers'
get_ethtool_statsno haveBUG_ON. Should we add theBUG_ONinto them?
[...]
The important thing is that the get_stats, get_sset_count and get_strings operations are consistent. Depending on how they are implemented, a BUG_ON or BUILD_BUG_ON may be useful to check that. I don't think there's any universal best practice.
Ben.
Signature · 2 lines
Ben Hutchings If at first you don't succeed, you're doing about average.
From: Wang Weidong <[email protected]>
Quoted 19 lines · Ben Hutchings
Quoted 11 lines · Wang Weidong
Quoted 10 lines · Ben Hutchings
Quoted 2 lines · Wang Weidong
when variable i go to the
BUG_ONthe value is equal to theCP_NUM_STATS, so theBUG_ONwon't occur, so remove itWe hope that every
BUG_ON()does not occur, but that doesn't mean they should be removed. This check is meant to catch mistakes when adding new statistics.Ben.
Quoted 7 lines
Hi, Ben.
Yeah, but I think If someone would add new statistics, he should take into account it instead the
BUG_ONhelper.And that, I found some other drivers'
get_ethtool_statsno haveBUG_ON. Should we add theBUG_ONinto them?
Quoted 9 lines
[...]
The important thing is that the
get_stats,get_sset_countandget_stringsoperations are consistent. Depending on how they are implemented, aBUG_ONorBUILD_BUG_ONmay be useful to check that. I don't think there's any universal best practice.Ben.
Ok, Got it.
Thanks for your answers.
Regards,
Wang