diff mbox series

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

Message ID 20211111103722.1650-1-zhang.mingyu@zte.com.cn (mailing list archive)
State New, archived
Headers show
Series blk-mq:Use BUG_ON instead of if condition followed by BUG. | expand

Commit Message

CGEL Nov. 11, 2021, 10:37 a.m. UTC
From: Zhang Mingyu <zhang.mingyu@zte.com.cn>

This issue was detected with the help of Coccinelle.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Zhang Mingyu <zhang.mingyu@zte.com.cn>
---
 block/blk-mq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Christoph Hellwig Nov. 12, 2021, 6:35 a.m. UTC | #1
On Thu, Nov 11, 2021 at 10:37:22AM +0000, cgel.zte@gmail.com wrote:
> From: Zhang Mingyu <zhang.mingyu@zte.com.cn>
> 
> This issue was detected with the help of Coccinelle.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Zhang Mingyu <zhang.mingyu@zte.com.cn>
> ---
>  block/blk-mq.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 7c5c8a26c8fc..05bffbc6b8ff 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -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.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 7c5c8a26c8fc..05bffbc6b8ff 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -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);