From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============0199189715699590917==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: [PATCH] scripts/dtc: fix bugon.cocci warnings Date: Fri, 21 May 2021 02:25:46 +0800 Message-ID: <20210520182546.GA50354@ad678c5af442> In-Reply-To: <202105210256.1Q2XDf1M-lkp@intel.com> List-Id: --===============0199189715699590917== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: kernel test robot 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 Signed-off-by: kernel test robot --- tree: https://android.googlesource.com/kernel/goldfish android-3.18 head: dd54b61f1458c03f68fc019b4874d98f2f0ae3a5 commit: 8214bf079208b146e63cd0a3ce0ed335a87ce7b3 [396/1051] scripts/dtc: Ex= port 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) =3D=3D -1) - BUG(); + BUG_ON(atomic_dec_return(&afs_outstanding_skbs) =3D=3D -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) =3D=3D -1) - BUG(); + BUG_ON(atomic_dec_return(&afs_outstanding_skbs) =3D=3D -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) =3D=3D -1) - BUG(); + BUG_ON(atomic_dec_return(&afs_outstanding_calls) =3D=3D -1); = ASSERTCMP(call->rxcall, =3D=3D, NULL); ASSERT(!work_pending(&call->async_work)); @@ -669,8 +666,7 @@ void afs_transfer_reply(struct afs_call { size_t len =3D 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 +=3D 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 =3D 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 +=3D len; = if (call->offset < 4) { @@ -850,9 +844,7 @@ int afs_extract_data(struct afs_call *ca ASSERTCMP(call->offset, <, count); = len =3D 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(s= kb, len)); call->offset +=3D len; = if (call->offset < count) { --===============0199189715699590917==--