Skip to contentSkip to conversation

staging: erofs: fix Warning Use BUG_ON instead of if condition followed by BUG

PATCH Superseded Hariprasad Kelam 3 participants 4 messages May 18, 2019 – May 20, 2019 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: erofs: fix Warning Use BUG_ON instead of if condition followed by BUG

fix below warning reported by coccicheck

drivers/staging/erofs/unzip_pagevec.h:74:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.

Signed-off-by Hariprasad Kelam <hariprasad.kelam at gmail.com>
---
 drivers/staging/erofs/unzip_pagevec.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/erofs/unzip_pagevec.h +1 -2
index f37d8fd..0f61c54 100644
@@ -70,8 +70,7 @@ z_erofs_pagevec_ctor_next_page(struct z_erofs_pagevec_ctor *ctor,
 			return tagptr_unfold_ptr(t);
 	}
 
-	if (unlikely(nr >= ctor->nr))
-		BUG();
+	BUG_ON(nr >= ctor->nr);
 
 	return NULL;
 }
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 staging: erofs: fix Warning Use BUG_ON instead of if condition followed by BUG

Hi Hariprasad,

Quoted 15 lines · Hariprasad Kelam

fix below warning reported by coccicheck

drivers/staging/erofs/unzip_pagevec.h:74:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.

Signed-off-by Hariprasad Kelam <hariprasad.kelam at gmail.com>
---
 drivers/staging/erofs/unzip_pagevec.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/erofs/unzip_pagevec.h +0 -0
index f37d8fd..0f61c54 100644

drivers/staging/erofs/unzip_pagevec.h z_erofs_pagevec_ctor_next_page(struct z_erofs_pagevec_ctor *ctor, · line 73

Quoted 6 lines
drivers/staging/erofs/unzip_pagevec.h +1 -2
@@ -70,8 +70,7 @@ z_erofs_pagevec_ctor_next_page(struct z_erofs_pagevec_ctor *ctor,
 			return tagptr_unfold_ptr(t);
 	}
 
-	if (unlikely(nr >= ctor->nr))
-		BUG();
+	BUG_ON(nr >= ctor->nr);

Thanks for your report. I suggest to use DBG_BUGON for this case, let me send another version for this case.

Thanks,
Gao Xiang

Quoted 4 lines
drivers/staging/erofs/unzip_pagevec.h +0 -0
 	return NULL;
 }
 
#2 lore raw

PATCH v2 1/1 staging: erofs: fix Warning Use BUG_ON instead of if condition followed by BUG

In reply to Hariprasad Kelam

From: Hariprasad Kelam <[email protected]>

fix below warning reported by coccicheck

drivers/staging/erofs/unzip_pagevec.h:74:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.

Signed-off-by Hariprasad Kelam <hariprasad.kelam at gmail.com>
[ Gao Xiang: use DBG_BUGON instead of BUG_ON for eng version only. ]
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>

---
change log v2:
- use DBG_BUGON as what said in the commit message.

Thanks,
Gao Xiang

 drivers/staging/erofs/unzip_pagevec.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/erofs/unzip_pagevec.h +1 -4
index f37d8fd14771..7af0ba8d8495 100644
@@ -69,10 +69,7 @@ z_erofs_pagevec_ctor_next_page(struct z_erofs_pagevec_ctor *ctor,
 		if (tags == Z_EROFS_PAGE_TYPE_EXCLUSIVE)
 			return tagptr_unfold_ptr(t);
 	}
-
-	if (unlikely(nr >= ctor->nr))
-		BUG();
-
+	DBG_BUGON(nr >= ctor->nr);
 	return NULL;
 }
 
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1
#3 lore raw
Quoted 10 lines · Gao Xiang

From: Hariprasad Kelam <hariprasad.kelam at gmail.com>

fix below warning reported by coccicheck

drivers/staging/erofs/unzip_pagevec.h:74:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.

Signed-off-by Hariprasad Kelam <hariprasad.kelam at gmail.com>
[ Gao Xiang: use DBG_BUGON instead of BUG_ON for eng version only. ]
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
Reviewed-by Chao Yu <yuchao0 at huawei.com>

Thanks,