Skip to content

Commit ebdec83

Browse files
SesterhennEricMark Fasheh
authored andcommitted
[PATCH] BUG_ON() Conversion in fs/ocfs2/
this changes if() BUG(); constructs to BUG_ON() which is cleaner, contains unlikely() and can better optimized away. Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de> Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
1 parent b4c7f53 commit ebdec83

4 files changed

Lines changed: 11 additions & 20 deletions

File tree

‎fs/ocfs2/extent_map.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
262262
el = &eb->h_list;
263263
}
264264

265-
if (el->l_tree_depth)
266-
BUG();
265+
BUG_ON(el->l_tree_depth);
267266

268267
for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) {
269268
rec = &el->l_recs[i];
@@ -364,8 +363,8 @@ static int ocfs2_extent_map_lookup_read(struct inode *inode,
364363
return ret;
365364
}
366365

367-
if (ent->e_tree_depth)
368-
BUG(); /* FIXME: Make sure this isn't a corruption */
366+
/* FIXME: Make sure this isn't a corruption */
367+
BUG_ON(ent->e_tree_depth);
369368

370369
*ret_ent = ent;
371370

@@ -423,8 +422,7 @@ static int ocfs2_extent_map_try_insert(struct inode *inode,
423422
le32_to_cpu(rec->e_clusters), NULL,
424423
NULL);
425424

426-
if (!old_ent)
427-
BUG();
425+
BUG_ON(!old_ent);
428426

429427
ret = -EEXIST;
430428
if (old_ent->e_tree_depth < tree_depth)

‎fs/ocfs2/journal.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
147147

148148
mlog_entry("(max_buffs = %d)\n", max_buffs);
149149

150-
if (!osb || !osb->journal->j_journal)
151-
BUG();
150+
BUG_ON(!osb || !osb->journal->j_journal);
152151

153152
if (ocfs2_is_hard_readonly(osb)) {
154153
ret = -EROFS;
@@ -672,8 +671,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
672671

673672
mlog_entry_void();
674673

675-
if (!osb)
676-
BUG();
674+
BUG_ON(!osb);
677675

678676
journal = osb->journal;
679677
if (!journal)
@@ -805,8 +803,7 @@ int ocfs2_journal_wipe(struct ocfs2_journal *journal, int full)
805803

806804
mlog_entry_void();
807805

808-
if (!journal)
809-
BUG();
806+
BUG_ON(!journal);
810807

811808
status = journal_wipe(journal->j_journal, full);
812809
if (status < 0) {
@@ -1271,8 +1268,7 @@ static int ocfs2_recover_node(struct ocfs2_super *osb,
12711268

12721269
/* Should not ever be called to recover ourselves -- in that
12731270
* case we should've called ocfs2_journal_load instead. */
1274-
if (osb->node_num == node_num)
1275-
BUG();
1271+
BUG_ON(osb->node_num == node_num);
12761272

12771273
slot_num = ocfs2_node_num_to_slot(si, node_num);
12781274
if (slot_num == OCFS2_INVALID_SLOT) {

‎fs/ocfs2/super.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,8 +1254,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
12541254
osb->sb = sb;
12551255
/* Save off for ocfs2_rw_direct */
12561256
osb->s_sectsize_bits = blksize_bits(sector_size);
1257-
if (!osb->s_sectsize_bits)
1258-
BUG();
1257+
BUG_ON(!osb->s_sectsize_bits);
12591258

12601259
osb->net_response_ids = 0;
12611260
spin_lock_init(&osb->net_response_lock);

‎fs/ocfs2/sysfile.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ struct inode *ocfs2_get_system_file_inode(struct ocfs2_super *osb,
7777
if (arr && ((inode = *arr) != NULL)) {
7878
/* get a ref in addition to the array ref */
7979
inode = igrab(inode);
80-
if (!inode)
81-
BUG();
80+
BUG_ON(!inode);
8281

8382
return inode;
8483
}
@@ -89,8 +88,7 @@ struct inode *ocfs2_get_system_file_inode(struct ocfs2_super *osb,
8988
/* add one more if putting into array for first time */
9089
if (arr && inode) {
9190
*arr = igrab(inode);
92-
if (!*arr)
93-
BUG();
91+
BUG_ON(!*arr);
9492
}
9593
return inode;
9694
}

0 commit comments

Comments
 (0)