[PATCH] ethernet: hnae: add unlikely() to assert()

Subsystems: hisilicon network subsystem driver, networking drivers, the rest

STALE2925d

3 messages, 2 authors, 2018-09-08 · open the first message on its own page

[PATCH] ethernet: hnae: add unlikely() to assert()

From: Igor Stoppa <hidden>
Date: 2018-09-07 17:27:03

The assert() condition is likely to be true.

Signed-off-by: Igor Stoppa <redacted>
Cc: huangdaode <redacted>
Cc: Yisen Zhuang <redacted>
Cc: Salil Mehta <redacted>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/hisilicon/hns/hnae.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
index 08a750fb60c4..bd3c180a3fe9 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -47,7 +47,7 @@
 #ifndef assert
 #define assert(expr) \
 do { \
-	if (!(expr)) { \
+	if (unlikely(!(expr))) { \
 		pr_err("Assertion failed! %s, %s, %s, line %d\n", \
 			   #expr, __FILE__, __func__, __LINE__); \
 	} \
-- 
2.17.1

Re: [PATCH] ethernet: hnae: add unlikely() to assert()

From: David Miller <davem@davemloft.net>
Date: 2018-09-07 21:47:05

From: Igor Stoppa <redacted>
Date: Fri,  7 Sep 2018 20:26:50 +0300
The assert() condition is likely to be true.
Worse than that is that drivers should not be definiting their own
private "assert()" macro.

I'd rather have that fixed instead.  We have tons of standard kernel
facilities that do what they are trying to do here, without overloading
the standard C namespace in this way.

Re: [PATCH] ethernet: hnae: add unlikely() to assert()

From: Igor Stoppa <hidden>
Date: 2018-09-08 15:00:34


On 08/09/18 00:46, David Miller wrote:
From: Igor Stoppa <redacted>
Date: Fri,  7 Sep 2018 20:26:50 +0300
quoted
The assert() condition is likely to be true.
Worse than that is that drivers should not be definiting their own
private "assert()" macro.

I'd rather have that fixed instead.  We have tons of standard kernel
facilities that do what they are trying to do here, without overloading
the standard C namespace in this way.
I've converted into WARN() what passed the compile test.
In one case it didn't even compile :-(

I could only compile-test.

--
igor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help