Thread (2 messages) 2 messages, 2 authors, 2021-04-29

RE: [PATCH] net/rxrpc: Use BUG_ON instead of if condition followed by BUG.

From: David Laight <hidden>
Date: 2021-04-29 08:48:25
Also in: lkml

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)
...
quoted hunk ↗ jump to hunk
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)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help