* [PATCH] ethernet: hnae: add unlikely() to assert()
@ 2018-09-07 17:26 Igor Stoppa
2018-09-07 21:46 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Igor Stoppa @ 2018-09-07 17:26 UTC (permalink / raw)
To: huangdaode
Cc: igor.stoppa, Igor Stoppa, Yisen Zhuang, Salil Mehta,
David S. Miller, netdev, linux-kernel
The assert() condition is likely to be true.
Signed-off-by: Igor Stoppa <igor.stoppa@huawei.com>
Cc: huangdaode <huangdaode@hisilicon.com>
Cc: Yisen Zhuang <yisen.zhuang@huawei.com>
Cc: Salil Mehta <salil.mehta@huawei.com>
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ethernet: hnae: add unlikely() to assert()
2018-09-07 17:26 [PATCH] ethernet: hnae: add unlikely() to assert() Igor Stoppa
@ 2018-09-07 21:46 ` David Miller
2018-09-08 15:00 ` Igor Stoppa
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2018-09-07 21:46 UTC (permalink / raw)
To: igor.stoppa
Cc: huangdaode, igor.stoppa, yisen.zhuang, salil.mehta, netdev,
linux-kernel
From: Igor Stoppa <igor.stoppa@gmail.com>
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ethernet: hnae: add unlikely() to assert()
2018-09-07 21:46 ` David Miller
@ 2018-09-08 15:00 ` Igor Stoppa
0 siblings, 0 replies; 3+ messages in thread
From: Igor Stoppa @ 2018-09-08 15:00 UTC (permalink / raw)
To: David Miller
Cc: huangdaode, igor.stoppa, yisen.zhuang, salil.mehta, netdev,
linux-kernel
On 08/09/18 00:46, David Miller wrote:
> From: Igor Stoppa <igor.stoppa@gmail.com>
> 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.
I've converted into WARN() what passed the compile test.
In one case it didn't even compile :-(
I could only compile-test.
--
igor
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-08 15:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-07 17:26 [PATCH] ethernet: hnae: add unlikely() to assert() Igor Stoppa
2018-09-07 21:46 ` David Miller
2018-09-08 15:00 ` Igor Stoppa
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).