Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1408495

[PATCH] mtd: Replace if and BUG with BUG_ON

From Amitoj Kaur Chawla <amitoj1606@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] mtd: Replace if and BUG with BUG_ON
Date 2016-05-28 18:50 +0200
Message-ID <rDPAZ-2Qo-1@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Replace if condition and BUG() with a BUG_ON having the conditional
expression of the if statement as argument.

The Coccinelle semantic patch used to make this change is as follows:
@@ expression E,f; @@

(
  if (<+... f(...) ...+>) { BUG(); }
|
- if (E) { BUG(); }
+ BUG_ON(E);
)

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/mtd/ssfdc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c
index daf82ba..41b13d1 100644
--- a/drivers/mtd/ssfdc.c
+++ b/drivers/mtd/ssfdc.c
@@ -380,8 +380,7 @@ static int ssfdcr_readsect(struct mtd_blktrans_dev *dev,
 		" block_addr=%d\n", logic_sect_no, sectors_per_block, offset,
 		block_address);
 
-	if (block_address >= ssfdc->map_len)
-		BUG();
+	BUG_ON(block_address >= ssfdc->map_len);
 
 	block_address = ssfdc->logic_block_map[block_address];
 
-- 
1.9.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] mtd: Replace if and BUG with BUG_ON Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-05-28 18:50 +0200
  Re: [PATCH] mtd: Replace if and BUG with BUG_ON Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> - 2016-05-31 00:20 +0200
    Re: [PATCH] mtd: Replace if and BUG with BUG_ON Julia Lawall <julia.lawall@lip6.fr> - 2016-05-31 07:50 +0200

csiph-web