lkml.org 
[lkml]   [2021]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] net/rxrpc: Use BUG_ON instead of if condition followed by BUG.
Date
From: zhouchuangao
> Sent: 29 April 2021 09:11
>
> BUG_ON() uses unlikely in if(), which can be optimized at compile time.
>
> do { if (unlikely(condition)) BUG(); } while (0)
...
> diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c
> index 4eb91d95..e5deb6f 100644
> --- a/net/rxrpc/call_object.c
> +++ b/net/rxrpc/call_object.c
> @@ -505,8 +505,7 @@ void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call)
> ASSERTCMP(call->state, ==, RXRPC_CALL_COMPLETE);
>
> spin_lock_bh(&call->lock);
> - if (test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags))
> - BUG();
> + BUG_ON(test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags));

Hiding as assignment inside BUG_ON() isn't nice.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

\
 
 \ /
  Last update: 2021-04-29 10:48    [W:0.064 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site