Skip to contentSkip to conversation

net/9p/trans_virtio.c: Use BUG_ON

PATCH Applied Julia Lawall 2 participants 2 messages Feb 17, 2008 – Feb 18, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 7/7 net/9p/trans_virtio.c: Use BUG_ON

From: Julia Lawall <[email protected]>

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>

---

net/9p/trans_virtio.c 2008-02-17 16:43:18.000000000 +0100 renamed from net/9p/trans_virtio.c 2008-02-10 22:34:18.000000000 +0100 +1 -2
diff -u -p a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
@@ -183,8 +183,7 @@ pack_sg_list(struct scatterlist *sg, int
 		sg_set_buf(&sg[index++], data, s);
 		count -= s;
 		data += s;
-		if (index > limit)
-			BUG();
+		BUG_ON(index > limit);
 	}
 
 	return index-start;
Applied
#1 lore raw

From: Julia Lawall <[email protected]>
Date: Sun, 17 Feb 2008 18:57:58 +0100 (CET)

Quoted 2 lines

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.

...

Quoted 1 line

Applied, thanks.