From: kernel test robot <lkp(a)intel.com>
fs/afs/rxrpc.c:152:3-6: WARNING: Use BUG_ON
fs/afs/rxrpc.c:741:2-5: WARNING: Use BUG_ON
fs/afs/rxrpc.c:743:2-5: WARNING: Use BUG_ON
fs/afs/rxrpc.c:855:2-5: WARNING: Use BUG_ON
fs/afs/rxrpc.c:182:2-5: WARNING: Use BUG_ON
fs/afs/rxrpc.c:169:3-6: WARNING: Use BUG_ON
fs/afs/rxrpc.c:673:2-5: WARNING: Use BUG_ON
Use BUG_ON instead of a if condition followed by BUG.
Semantic patch information:
This makes an effort to find cases where BUG() follows an if
condition on an expression and replaces the if condition and BUG()
with a BUG_ON having the conditional expression of the if statement
as argument.
Generated by: scripts/coccinelle/misc/bugon.cocci
Fixes: 8214bf079208 ("scripts/dtc: Export YYLOC global declaration")
Reported-by: kernel test robot <lkp(a)intel.com>
Signed-off-by: kernel test robot <lkp(a)intel.com>
---
tree:
https://android.googlesource.com/kernel/goldfish android-3.18
head: dd54b61f1458c03f68fc019b4874d98f2f0ae3a5
commit: 8214bf079208b146e63cd0a3ce0ed335a87ce7b3 [396/1051] scripts/dtc: Export YYLOC
global declaration
:::::: branch date: 5 weeks ago
:::::: commit date: 3 months ago
Please take the patch only if it's a positive warning. Thanks!
rxrpc.c | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
--- a/fs/afs/rxrpc.c
+++ b/fs/afs/rxrpc.c
@@ -148,8 +148,7 @@ static void afs_data_delivered(struct sk
} else {
_debug("DLVR %p{%u} [%d]",
skb, skb->mark, atomic_read(&afs_outstanding_skbs));
- if (atomic_dec_return(&afs_outstanding_skbs) == -1)
- BUG();
+ BUG_ON(atomic_dec_return(&afs_outstanding_skbs) == -1);
rxrpc_kernel_data_delivered(skb);
}
}
@@ -165,8 +164,7 @@ static void afs_free_skb(struct sk_buff
} else {
_debug("FREE %p{%u} [%d]",
skb, skb->mark, atomic_read(&afs_outstanding_skbs));
- if (atomic_dec_return(&afs_outstanding_skbs) == -1)
- BUG();
+ BUG_ON(atomic_dec_return(&afs_outstanding_skbs) == -1);
rxrpc_kernel_free_skb(skb);
}
}
@@ -178,8 +176,7 @@ static void afs_free_call(struct afs_cal
{
_debug("DONE %p{%s} [%d]",
call, call->type->name, atomic_read(&afs_outstanding_calls));
- if (atomic_dec_return(&afs_outstanding_calls) == -1)
- BUG();
+ BUG_ON(atomic_dec_return(&afs_outstanding_calls) == -1);
ASSERTCMP(call->rxcall, ==, NULL);
ASSERT(!work_pending(&call->async_work));
@@ -669,8 +666,7 @@ void afs_transfer_reply(struct afs_call
{
size_t len = skb->len;
- if (skb_copy_bits(skb, 0, call->buffer + call->reply_size, len) < 0)
- BUG();
+ BUG_ON(skb_copy_bits(skb, 0, call->buffer + call->reply_size, len) < 0);
call->reply_size += len;
}
@@ -737,10 +733,8 @@ static int afs_deliver_cm_op_id(struct a
/* the operation ID forms the first four bytes of the request data */
len = min_t(size_t, len, 4 - call->offset);
- if (skb_copy_bits(skb, 0, oibuf + call->offset, len) < 0)
- BUG();
- if (!pskb_pull(skb, len))
- BUG();
+ BUG_ON(skb_copy_bits(skb, 0, oibuf + call->offset, len) < 0);
+ BUG_ON(!pskb_pull(skb, len));
call->offset += len;
if (call->offset < 4) {
@@ -850,9 +844,7 @@ int afs_extract_data(struct afs_call *ca
ASSERTCMP(call->offset, <, count);
len = min_t(size_t, len, count - call->offset);
- if (skb_copy_bits(skb, 0, buf + call->offset, len) < 0 ||
- !pskb_pull(skb, len))
- BUG();
+ BUG_ON(skb_copy_bits(skb, 0, buf + call->offset, len) < 0 || !pskb_pull(skb,
len));
call->offset += len;
if (call->offset < count) {