Skip to contentSkip to conversation

rxrpc: call_accept: use BUG_ON instead of if condition followed by BUG

PATCH New Gustavo A. R. Silva 1 participant 1 message Oct 24, 2017

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

PATCH 1/1 rxrpc: call_accept: use BUG_ON instead of if condition followed by BUG

Use BUG_ON instead of if condition followed by BUG.

This issue was detected with the help of Coccinelle.

---
 net/rxrpc/call_accept.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/rxrpc/call_accept.c +2 -4
index cbd1701..1fd270f 100644
@@ -387,8 +387,7 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,
 	 * event and userspace is prevented from doing so until the state is
 	 * appropriate.
 	 */
-	if (!mutex_trylock(&call->user_mutex))
-		BUG();
+	BUG_ON(!mutex_trylock(&call->user_mutex));
 
 	/* Make the call live. */
 	rxrpc_incoming_call(rx, call, skb);
@@ -543,8 +542,7 @@ struct rxrpc_call *rxrpc_accept_call(struct rxrpc_sock *rx,
 	rxrpc_get_call(call, rxrpc_call_got_userid);
 	rb_link_node(&call->sock_node, parent, pp);
 	rb_insert_color(&call->sock_node, &rx->calls);
-	if (test_and_set_bit(RXRPC_CALL_HAS_USERID, &call->flags))
-		BUG();
+	BUG_ON(test_and_set_bit(RXRPC_CALL_HAS_USERID, &call->flags));
 
 	write_unlock_bh(&call->state_lock);
 	write_unlock(&rx->call_lock);
Signature · 1 line
2.7.4