Skip to content

Commit

Permalink
target: Convert target_core_rd.c to use use BUG_ON
Browse files Browse the repository at this point in the history
Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Julia Lawall authored and Nicholas Bellinger committed Aug 22, 2011
1 parent 9be08c5 commit 6fc6148
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions drivers/target/target_core_rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,10 @@ static int rd_MEMCPY_read(struct rd_request *req)
length = req->rd_size;

dst = sg_virt(&sg_d[i++]) + dst_offset;
if (!dst)
BUG();
BUG_ON(!dst);

src = sg_virt(&sg_s[j]) + src_offset;
if (!src)
BUG();
BUG_ON(!src);

dst_offset = 0;
src_offset = length;
Expand All @@ -415,8 +413,7 @@ static int rd_MEMCPY_read(struct rd_request *req)
length = req->rd_size;

dst = sg_virt(&sg_d[i]) + dst_offset;
if (!dst)
BUG();
BUG_ON(!dst);

if (sg_d[i].length == length) {
i++;
Expand All @@ -425,8 +422,7 @@ static int rd_MEMCPY_read(struct rd_request *req)
dst_offset = length;

src = sg_virt(&sg_s[j++]) + src_offset;
if (!src)
BUG();
BUG_ON(!src);

src_offset = 0;
page_end = 1;
Expand Down Expand Up @@ -510,12 +506,10 @@ static int rd_MEMCPY_write(struct rd_request *req)
length = req->rd_size;

src = sg_virt(&sg_s[i++]) + src_offset;
if (!src)
BUG();
BUG_ON(!src);

dst = sg_virt(&sg_d[j]) + dst_offset;
if (!dst)
BUG();
BUG_ON(!dst);

src_offset = 0;
dst_offset = length;
Expand All @@ -535,8 +529,7 @@ static int rd_MEMCPY_write(struct rd_request *req)
length = req->rd_size;

src = sg_virt(&sg_s[i]) + src_offset;
if (!src)
BUG();
BUG_ON(!src);

if (sg_s[i].length == length) {
i++;
Expand All @@ -545,8 +538,7 @@ static int rd_MEMCPY_write(struct rd_request *req)
src_offset = length;

dst = sg_virt(&sg_d[j++]) + dst_offset;
if (!dst)
BUG();
BUG_ON(!dst);

dst_offset = 0;
page_end = 1;
Expand Down

0 comments on commit 6fc6148

Please sign in to comment.