Skip to contentSkip to conversation

fs/ocfs2: 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 3/7 fs/ocfs2: 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>

---

fs/ocfs2/alloc.c 2008-02-17 16:40:41.000000000 +0100 renamed from fs/ocfs2/alloc.c 2008-02-05 20:56:02.000000000 +0100 +1 -2
diff -u -p a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
@@ -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
fs/ocfs2/journal.c 2008-02-17 16:40:59.000000000 +0100 renamed from fs/ocfs2/journal.c 2008-02-02 16:09:08.000000000 +0100 +1 -2
diff -u -p a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
@@ -586,8 +586,7 @@ int ocfs2_journal_load(struct ocfs2_jour
 
 	mlog_entry_void();
 
-	if (!journal)
-		BUG();
+	BUG_ON(!journal);
 
 	osb = journal->j_osb;
 
Acked-by on v1 3/7
#1 lore raw
Quoted 28 lines · Julia Lawall

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>

Quoted 1 line

--
Mark Fasheh
Principal Software Developer, Oracle
[email protected]