Skip to contentSkip to conversation

net: bcmgenet: Use BUG_ON instead of if condition followed by BUG

PATCH Applied Gustavo A. R. Silva 2 participants 2 messages Oct 26, 2017 – Oct 27, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: bcmgenet: Use BUG_ON instead of if condition followed by BUG

Use BUG_ON instead of if condition followed by BUG.

Something to notice in this particular case is that unlikely() is already being called inside BUG_ON macro.

This issue was detected with the help of Coccinelle.

---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +1 -2
index 9cebca8..0d1cb06 100644
@@ -1584,8 +1584,7 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
 	for (i = 0; i <= nr_frags; i++) {
 		tx_cb_ptr = bcmgenet_get_txcb(priv, ring);
 
-		if (unlikely(!tx_cb_ptr))
-			BUG();
+		BUG_ON(!tx_cb_ptr);
 
 		if (!i) {
 			/* Transmit single SKB or head of fragment list */
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

From: "Gustavo A. R. Silva" <[email protected]>
Date: Thu, 26 Oct 2017 07:16:01 -0500

Quoted 8 lines

Use BUG_ON instead of if condition followed by BUG.

Something to notice in this particular case is that unlikely() is already being called inside BUG_ON macro.

This issue was detected with the help of Coccinelle.

Applied.