mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 7/7] net/9p/trans_virtio.c: Use BUG_ON
@ 2008-02-17 17:57 Julia Lawall
  2008-02-18  2:43 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2008-02-17 17:57 UTC (permalink / raw)
  To: ericvh, rminnich, lucho, v9fs-developer, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

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>

---

diff -u -p a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
--- a/net/9p/trans_virtio.c 2008-02-10 22:34:18.000000000 +0100
+++ b/net/9p/trans_virtio.c 2008-02-17 16:43:18.000000000 +0100
@@ -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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-18  2:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-17 17:57 [PATCH 7/7] net/9p/trans_virtio.c: Use BUG_ON Julia Lawall
2008-02-18  2:43 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®