netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH net-next] xfrm: use BUG_ON instead of if condition followed by BUG
  2021-06-07  9:11 [PATCH net-next] xfrm: use BUG_ON instead of if condition followed by BUG Zheng Yongjun
@ 2021-06-07  9:04 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2021-06-07  9:04 UTC (permalink / raw)
  To: Zheng Yongjun; +Cc: steffen.klassert, davem, kuba, netdev, linux-kernel

On Mon, Jun 07, 2021 at 05:11:21PM +0800, Zheng Yongjun wrote:
> Use BUG_ON instead of if condition followed by BUG.
> 
> This issue was detected with the help of Coccinelle.
> 
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
>  net/xfrm/xfrm_policy.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index ce500f847b99..532314578151 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -421,8 +421,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
>  {
>  	BUG_ON(!policy->walk.dead);
>  
> -	if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
> -		BUG();
> +	BUG_ON(del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer));

Nack.  Do not put statements with side effects within BUG_ON.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* [PATCH net-next] xfrm: use BUG_ON instead of if condition followed by BUG
@ 2021-06-07  9:11 Zheng Yongjun
  2021-06-07  9:04 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Zheng Yongjun @ 2021-06-07  9:11 UTC (permalink / raw)
  To: steffen.klassert, herbert, davem, kuba, netdev, linux-kernel
  Cc: Zheng Yongjun

Use BUG_ON instead of if condition followed by BUG.

This issue was detected with the help of Coccinelle.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 net/xfrm/xfrm_policy.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index ce500f847b99..532314578151 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -421,8 +421,7 @@ void xfrm_policy_destroy(struct xfrm_policy *policy)
 {
 	BUG_ON(!policy->walk.dead);
 
-	if (del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer))
-		BUG();
+	BUG_ON(del_timer(&policy->timer) || del_timer(&policy->polq.hold_timer));
 
 	call_rcu(&policy->rcu, xfrm_policy_destroy_rcu);
 }
-- 
2.25.1


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

end of thread, other threads:[~2021-06-07  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07  9:11 [PATCH net-next] xfrm: use BUG_ON instead of if condition followed by BUG Zheng Yongjun
2021-06-07  9:04 ` Herbert Xu

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).