Skip to content

Commit

Permalink
ocfs2: 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
  • Loading branch information
Julia Lawall authored and Mark Fasheh committed Apr 18, 2008
1 parent c9ec148 commit b1f3550
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions fs/ocfs2/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,7 @@ static void ocfs2_rotate_leaf(struct ocfs2_extent_list *el,
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
Expand Down
3 changes: 1 addition & 2 deletions fs/ocfs2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,7 @@ int ocfs2_journal_load(struct ocfs2_journal *journal, int local)

mlog_entry_void();

if (!journal)
BUG();
BUG_ON(!journal);

osb = journal->j_osb;

Expand Down

0 comments on commit b1f3550

Please sign in to comment.