Skip to content

Commit

Permalink
net/9p/trans_virtio.c: Use BUG_ON
Browse files Browse the repository at this point in the history
if (...) BUG(); should be replaced with BUG_ON(...) when the test has no
side-effects to allow a definition of BUG_ON that drops the code completely.

The semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@ disable unlikely @ expression E,f; @@

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

@@ expression E,f; @@

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

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Julia Lawall authored and David S. Miller committed Feb 18, 2008
1 parent 163e3cb commit d6584f3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/9p/trans_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ pack_sg_list(struct scatterlist *sg, int start, int limit, char *data,
sg_set_buf(&sg[index++], data, s);
count -= s;
data += s;
if (index > limit)
BUG();
BUG_ON(index > limit);
}

return index-start;
Expand Down

0 comments on commit d6584f3

Please sign in to comment.