LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 3/7] fs/ocfs2: Use BUG_ON
@ 2008-02-17 17:55 Julia Lawall
  2008-02-18 20:14 ` Mark Fasheh
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2008-02-17 17:55 UTC (permalink / raw)
  To: mark.fasheh, kurt.hackel, ocfs2-devel, 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/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
--- a/fs/ocfs2/alloc.c 2008-02-05 20:56:02.000000000 +0100
+++ b/fs/ocfs2/alloc.c 2008-02-17 16:40:41.000000000 +0100
@@ -1029,8 +1029,7 @@ static void ocfs2_rotate_leaf(struct ocf
 	BUG_ON(!next_free);
 
 	/* The tree code before us didn't allow enough room in the leaf. */
-	if (el->l_next_free_rec == el->l_count && !has_empty)
-		BUG();
+	BUG_ON(el->l_next_free_rec == el->l_count && !has_empty);
 
 	/*
 	 * The easiest way to approach this is to just remove the
diff -u -p a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
--- a/fs/ocfs2/journal.c 2008-02-02 16:09:08.000000000 +0100
+++ b/fs/ocfs2/journal.c 2008-02-17 16:40:59.000000000 +0100
@@ -586,8 +586,7 @@ int ocfs2_journal_load(struct ocfs2_jour
 
 	mlog_entry_void();
 
-	if (!journal)
-		BUG();
+	BUG_ON(!journal);
 
 	osb = journal->j_osb;
 

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

* Re: [PATCH 3/7] fs/ocfs2: Use BUG_ON
  2008-02-17 17:55 [PATCH 3/7] fs/ocfs2: Use BUG_ON Julia Lawall
@ 2008-02-18 20:14 ` Mark Fasheh
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Fasheh @ 2008-02-18 20:14 UTC (permalink / raw)
  To: Julia Lawall; +Cc: kurt.hackel, ocfs2-devel, linux-kernel, kernel-janitors

On Sun, Feb 17, 2008 at 06:55:49PM +0100, Julia Lawall wrote:
> 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>
Acked-by: Mark Fasheh <mark.fasheh@oracle.com>

--
Mark Fasheh
Principal Software Developer, Oracle
mark.fasheh@oracle.com

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

end of thread, other threads:[~2008-02-18 20:17 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:55 [PATCH 3/7] fs/ocfs2: Use BUG_ON Julia Lawall
2008-02-18 20:14 ` Mark Fasheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).