Skip to contentSkip to conversation

ethernet: hnae: add unlikely() to assert()

PATCH In review Igor Stoppa 2 participants 3 messages Sep 7, 2018 – Sep 8, 2018

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

PATCH 1/1 ethernet: hnae: add unlikely() to assert()

The assert() condition is likely to be true.

Cc huangdaode <[email protected]>
Cc Yisen Zhuang <[email protected]>
Cc Salil Mehta <[email protected]>
Cc "David S. Miller" <[email protected]>
---
 drivers/net/ethernet/hisilicon/hns/hnae.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns/hnae.h +1 -1
index 08a750fb60c4..bd3c180a3fe9 100644
@@ -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__); \
 	} \
Signature · 1 line
2.17.1
maintainer
#1 lore raw

From: Igor Stoppa <[email protected]>
Date: Fri, 7 Sep 2018 20:26:50 +0300

Quoted 1 line

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.

#2 lore raw
Quoted 11 lines · David Miller

From: Igor Stoppa <[email protected]>
Date: Fri, 7 Sep 2018 20:26:50 +0300

Quoted 1 line

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