netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: faraday: ftmac100: Use BUG_ON instead of if condition followed by BUG.
@ 2017-10-26 12:27 Gustavo A. R. Silva
  2017-10-27 14:56 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2017-10-26 12:27 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, Gustavo A. R. Silva

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

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/net/ethernet/faraday/ftmac100.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
index 66928a9..aecc765 100644
--- a/drivers/net/ethernet/faraday/ftmac100.c
+++ b/drivers/net/ethernet/faraday/ftmac100.c
@@ -402,6 +402,7 @@ static bool ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
 	struct page *page;
 	dma_addr_t map;
 	int length;
+	bool ret;
 
 	rxdes = ftmac100_rx_locate_first_segment(priv);
 	if (!rxdes)
@@ -416,8 +417,8 @@ static bool ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
 	 * It is impossible to get multi-segment packets
 	 * because we always provide big enough receive buffers.
 	 */
-	if (unlikely(!ftmac100_rxdes_last_segment(rxdes)))
-		BUG();
+	ret = ftmac100_rxdes_last_segment(rxdes);
+	BUG_ON(!ret);
 
 	/* start processing */
 	skb = netdev_alloc_skb_ip_align(netdev, 128);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: faraday: ftmac100: Use BUG_ON instead of if condition followed by BUG.
  2017-10-26 12:27 [PATCH] net: faraday: ftmac100: Use BUG_ON instead of if condition followed by BUG Gustavo A. R. Silva
@ 2017-10-27 14:56 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-10-27 14:56 UTC (permalink / raw)
  To: garsilva; +Cc: netdev, linux-kernel

From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Date: Thu, 26 Oct 2017 07:27:45 -0500

> Notice that in this particular case unlikely() is already being called
> inside BUG_ON macro.
> 
> This issue was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-27 14:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-26 12:27 [PATCH] net: faraday: ftmac100: Use BUG_ON instead of if condition followed by BUG Gustavo A. R. Silva
2017-10-27 14:56 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).