Skip to contentSkip to conversation

blk-mq:Use BUG_ON instead of if condition followed by BUG.

PATCH In review [email protected] 2 participants 2 messages Nov 11, 2021 – Nov 12, 2021 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-mq:Use BUG_ON instead of if condition followed by BUG.

From: Zhang Mingyu <[email protected]>

This issue was detected with the help of Coccinelle.

---
 block/blk-mq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-mq.c +1 -2
index 7c5c8a26c8fc..05bffbc6b8ff 100644
@@ -818,8 +818,7 @@ EXPORT_SYMBOL(__blk_mq_end_request);
 
 void blk_mq_end_request(struct request *rq, blk_status_t error)
 {
-	if (blk_update_request(rq, error, blk_rq_bytes(rq)))
-		BUG();
+	BUG_ON(blk_update_request(rq, error, blk_rq_bytes(rq)));
 	__blk_mq_end_request(rq, error);
 }
 EXPORT_SYMBOL(blk_mq_end_request);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 15 lines · On Thu, Nov 11, 2021 at 10:37:22AM +0000, [email protected] wrote:

From: Zhang Mingyu <[email protected]>

This issue was detected with the help of Coccinelle.

---
 block/blk-mq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-mq.c +0 -0
index 7c5c8a26c8fc..05bffbc6b8ff 100644

block/blk-mq.c EXPORT_SYMBOL(__blk_mq_end_request); · line 821

Quoted 6 lines
block/blk-mq.c +1 -2
@@ -818,8 +818,7 @@ EXPORT_SYMBOL(__blk_mq_end_request);
 
 void blk_mq_end_request(struct request *rq, blk_status_t error)
 {
-	if (blk_update_request(rq, error, blk_rq_bytes(rq)))
-		BUG();
+	BUG_ON(blk_update_request(rq, error, blk_rq_bytes(rq)));

Err, no. This now moves the actually important condition into the BUG_ON macro and makes the function a complete mess.