diff options
author | Eric Sesterhenn <snakebyte@gmx.de> | 2006-10-03 17:36:38 -0400 |
---|---|---|
committer | Adrian Bunk <bunk@stusta.de> | 2006-10-03 17:36:38 -0400 |
commit | 14a61442c2203d2a49f2f954bfa9259c0ddac1aa (patch) | |
tree | c146effc3dbaa41dd6fdd01e6f3f8fcdd63ad705 /fs/reiserfs | |
parent | 8d8f3cbe777e014123bfa63f2cebd6eb29032225 (diff) |
BUG_ON conversion for fs/reiserfs
This patch converts several if () BUG(); construct to BUG_ON();
which occupies less space, uses unlikely and is safer when
BUG() is disabled. S_ISREG() has no side effects, so the
conversion is safe.
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Diffstat (limited to 'fs/reiserfs')
-rw-r--r-- | fs/reiserfs/file.c | 6 | ||||
-rw-r--r-- | fs/reiserfs/item_ops.c | 12 | ||||
-rw-r--r-- | fs/reiserfs/journal.c | 49 | ||||
-rw-r--r-- | fs/reiserfs/namei.c | 9 | ||||
-rw-r--r-- | fs/reiserfs/stree.c | 4 |
5 files changed, 26 insertions, 54 deletions
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index 41f24369e47a..c093642fb983 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c | |||
@@ -38,8 +38,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp) | |||
38 | int err; | 38 | int err; |
39 | int jbegin_failure = 0; | 39 | int jbegin_failure = 0; |
40 | 40 | ||
41 | if (!S_ISREG(inode->i_mode)) | 41 | BUG_ON(!S_ISREG(inode->i_mode)); |
42 | BUG(); | ||
43 | 42 | ||
44 | /* fast out for when nothing needs to be done */ | 43 | /* fast out for when nothing needs to be done */ |
45 | if ((atomic_read(&inode->i_count) > 1 || | 44 | if ((atomic_read(&inode->i_count) > 1 || |
@@ -125,8 +124,7 @@ static int reiserfs_sync_file(struct file *p_s_filp, | |||
125 | int n_err; | 124 | int n_err; |
126 | int barrier_done; | 125 | int barrier_done; |
127 | 126 | ||
128 | if (!S_ISREG(p_s_inode->i_mode)) | 127 | BUG_ON(!S_ISREG(p_s_inode->i_mode)); |
129 | BUG(); | ||
130 | n_err = sync_mapping_buffers(p_s_inode->i_mapping); | 128 | n_err = sync_mapping_buffers(p_s_inode->i_mapping); |
131 | reiserfs_write_lock(p_s_inode->i_sb); | 129 | reiserfs_write_lock(p_s_inode->i_sb); |
132 | barrier_done = reiserfs_commit_for_inode(p_s_inode); | 130 | barrier_done = reiserfs_commit_for_inode(p_s_inode); |
diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c index 7a88adbceef6..b9b423b22a8b 100644 --- a/fs/reiserfs/item_ops.c +++ b/fs/reiserfs/item_ops.c | |||
@@ -75,8 +75,7 @@ static int sd_create_vi(struct virtual_node *vn, | |||
75 | static int sd_check_left(struct virtual_item *vi, int free, | 75 | static int sd_check_left(struct virtual_item *vi, int free, |
76 | int start_skip, int end_skip) | 76 | int start_skip, int end_skip) |
77 | { | 77 | { |
78 | if (start_skip || end_skip) | 78 | BUG_ON(start_skip || end_skip); |
79 | BUG(); | ||
80 | return -1; | 79 | return -1; |
81 | } | 80 | } |
82 | 81 | ||
@@ -87,8 +86,7 @@ static int sd_check_right(struct virtual_item *vi, int free) | |||
87 | 86 | ||
88 | static int sd_part_size(struct virtual_item *vi, int first, int count) | 87 | static int sd_part_size(struct virtual_item *vi, int first, int count) |
89 | { | 88 | { |
90 | if (count) | 89 | BUG_ON(count); |
91 | BUG(); | ||
92 | return 0; | 90 | return 0; |
93 | } | 91 | } |
94 | 92 | ||
@@ -476,8 +474,7 @@ static int direntry_create_vi(struct virtual_node *vn, | |||
476 | 474 | ||
477 | vi->vi_index = TYPE_DIRENTRY; | 475 | vi->vi_index = TYPE_DIRENTRY; |
478 | 476 | ||
479 | if (!(vi->vi_ih) || !vi->vi_item) | 477 | BUG_ON(!(vi->vi_ih) || !vi->vi_item); |
480 | BUG(); | ||
481 | 478 | ||
482 | dir_u->flags = 0; | 479 | dir_u->flags = 0; |
483 | if (le_ih_k_offset(vi->vi_ih) == DOT_OFFSET) | 480 | if (le_ih_k_offset(vi->vi_ih) == DOT_OFFSET) |
@@ -575,8 +572,7 @@ static int direntry_check_right(struct virtual_item *vi, int free) | |||
575 | free -= dir_u->entry_sizes[i]; | 572 | free -= dir_u->entry_sizes[i]; |
576 | entries++; | 573 | entries++; |
577 | } | 574 | } |
578 | if (entries == dir_u->entry_count) | 575 | BUG_ON(entries == dir_u->entry_count); |
579 | BUG(); | ||
580 | 576 | ||
581 | /* "." and ".." can not be separated from each other */ | 577 | /* "." and ".." can not be separated from each other */ |
582 | if ((dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM) | 578 | if ((dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM) |
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index e6b5ccf23f15..ad8cbc49883a 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -718,8 +718,7 @@ static int add_to_chunk(struct buffer_chunk *chunk, struct buffer_head *bh, | |||
718 | spinlock_t * lock, void (fn) (struct buffer_chunk *)) | 718 | spinlock_t * lock, void (fn) (struct buffer_chunk *)) |
719 | { | 719 | { |
720 | int ret = 0; | 720 | int ret = 0; |
721 | if (chunk->nr >= CHUNK_SIZE) | 721 | BUG_ON(chunk->nr >= CHUNK_SIZE); |
722 | BUG(); | ||
723 | chunk->bh[chunk->nr++] = bh; | 722 | chunk->bh[chunk->nr++] = bh; |
724 | if (chunk->nr >= CHUNK_SIZE) { | 723 | if (chunk->nr >= CHUNK_SIZE) { |
725 | ret = 1; | 724 | ret = 1; |
@@ -788,8 +787,7 @@ static inline int __add_jh(struct reiserfs_journal *j, struct buffer_head *bh, | |||
788 | /* buffer must be locked for __add_jh, should be able to have | 787 | /* buffer must be locked for __add_jh, should be able to have |
789 | * two adds at the same time | 788 | * two adds at the same time |
790 | */ | 789 | */ |
791 | if (bh->b_private) | 790 | BUG_ON(bh->b_private); |
792 | BUG(); | ||
793 | jh->bh = bh; | 791 | jh->bh = bh; |
794 | bh->b_private = jh; | 792 | bh->b_private = jh; |
795 | } | 793 | } |
@@ -2967,8 +2965,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th, | |||
2967 | int retval; | 2965 | int retval; |
2968 | 2966 | ||
2969 | reiserfs_check_lock_depth(p_s_sb, "journal_begin"); | 2967 | reiserfs_check_lock_depth(p_s_sb, "journal_begin"); |
2970 | if (nblocks > journal->j_trans_max) | 2968 | BUG_ON(nblocks > journal->j_trans_max); |
2971 | BUG(); | ||
2972 | 2969 | ||
2973 | PROC_INFO_INC(p_s_sb, journal.journal_being); | 2970 | PROC_INFO_INC(p_s_sb, journal.journal_being); |
2974 | /* set here for journal_join */ | 2971 | /* set here for journal_join */ |
@@ -3084,9 +3081,8 @@ struct reiserfs_transaction_handle *reiserfs_persistent_transaction(struct | |||
3084 | if (reiserfs_transaction_running(s)) { | 3081 | if (reiserfs_transaction_running(s)) { |
3085 | th = current->journal_info; | 3082 | th = current->journal_info; |
3086 | th->t_refcount++; | 3083 | th->t_refcount++; |
3087 | if (th->t_refcount < 2) { | 3084 | BUG_ON(th->t_refcount < 2); |
3088 | BUG(); | 3085 | |
3089 | } | ||
3090 | return th; | 3086 | return th; |
3091 | } | 3087 | } |
3092 | th = kmalloc(sizeof(struct reiserfs_transaction_handle), GFP_NOFS); | 3088 | th = kmalloc(sizeof(struct reiserfs_transaction_handle), GFP_NOFS); |
@@ -3126,9 +3122,7 @@ static int journal_join(struct reiserfs_transaction_handle *th, | |||
3126 | ** pointer | 3122 | ** pointer |
3127 | */ | 3123 | */ |
3128 | th->t_handle_save = cur_th; | 3124 | th->t_handle_save = cur_th; |
3129 | if (cur_th && cur_th->t_refcount > 1) { | 3125 | BUG_ON(cur_th && cur_th->t_refcount > 1); |
3130 | BUG(); | ||
3131 | } | ||
3132 | return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_JOIN); | 3126 | return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_JOIN); |
3133 | } | 3127 | } |
3134 | 3128 | ||
@@ -3141,9 +3135,7 @@ int journal_join_abort(struct reiserfs_transaction_handle *th, | |||
3141 | ** pointer | 3135 | ** pointer |
3142 | */ | 3136 | */ |
3143 | th->t_handle_save = cur_th; | 3137 | th->t_handle_save = cur_th; |
3144 | if (cur_th && cur_th->t_refcount > 1) { | 3138 | BUG_ON(cur_th && cur_th->t_refcount > 1); |
3145 | BUG(); | ||
3146 | } | ||
3147 | return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_ABORT); | 3139 | return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_ABORT); |
3148 | } | 3140 | } |
3149 | 3141 | ||
@@ -3178,8 +3170,7 @@ int journal_begin(struct reiserfs_transaction_handle *th, | |||
3178 | current->journal_info = th; | 3170 | current->journal_info = th; |
3179 | } | 3171 | } |
3180 | ret = do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_REG); | 3172 | ret = do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_REG); |
3181 | if (current->journal_info != th) | 3173 | BUG_ON(current->journal_info != th); |
3182 | BUG(); | ||
3183 | 3174 | ||
3184 | /* I guess this boils down to being the reciprocal of clm-2100 above. | 3175 | /* I guess this boils down to being the reciprocal of clm-2100 above. |
3185 | * If do_journal_begin_r fails, we need to put it back, since journal_end | 3176 | * If do_journal_begin_r fails, we need to put it back, since journal_end |
@@ -3324,8 +3315,7 @@ int journal_end(struct reiserfs_transaction_handle *th, | |||
3324 | /* we aren't allowed to close a nested transaction on a different | 3315 | /* we aren't allowed to close a nested transaction on a different |
3325 | ** filesystem from the one in the task struct | 3316 | ** filesystem from the one in the task struct |
3326 | */ | 3317 | */ |
3327 | if (cur_th->t_super != th->t_super) | 3318 | BUG_ON(cur_th->t_super != th->t_super); |
3328 | BUG(); | ||
3329 | 3319 | ||
3330 | if (th != cur_th) { | 3320 | if (th != cur_th) { |
3331 | memcpy(current->journal_info, th, sizeof(*th)); | 3321 | memcpy(current->journal_info, th, sizeof(*th)); |
@@ -3444,9 +3434,7 @@ int journal_end_sync(struct reiserfs_transaction_handle *th, | |||
3444 | 3434 | ||
3445 | BUG_ON(!th->t_trans_id); | 3435 | BUG_ON(!th->t_trans_id); |
3446 | /* you can sync while nested, very, very bad */ | 3436 | /* you can sync while nested, very, very bad */ |
3447 | if (th->t_refcount > 1) { | 3437 | BUG_ON(th->t_refcount > 1); |
3448 | BUG(); | ||
3449 | } | ||
3450 | if (journal->j_len == 0) { | 3438 | if (journal->j_len == 0) { |
3451 | reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), | 3439 | reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), |
3452 | 1); | 3440 | 1); |
@@ -3556,9 +3544,8 @@ static int check_journal_end(struct reiserfs_transaction_handle *th, | |||
3556 | ** will be dealt with by next transaction that actually writes something, but should be taken | 3544 | ** will be dealt with by next transaction that actually writes something, but should be taken |
3557 | ** care of in this trans | 3545 | ** care of in this trans |
3558 | */ | 3546 | */ |
3559 | if (journal->j_len == 0) { | 3547 | BUG_ON(journal->j_len == 0); |
3560 | BUG(); | 3548 | |
3561 | } | ||
3562 | /* if wcount > 0, and we are called to with flush or commit_now, | 3549 | /* if wcount > 0, and we are called to with flush or commit_now, |
3563 | ** we wait on j_join_wait. We will wake up when the last writer has | 3550 | ** we wait on j_join_wait. We will wake up when the last writer has |
3564 | ** finished the transaction, and started it on its way to the disk. | 3551 | ** finished the transaction, and started it on its way to the disk. |
@@ -3592,9 +3579,8 @@ static int check_journal_end(struct reiserfs_transaction_handle *th, | |||
3592 | unlock_journal(p_s_sb); | 3579 | unlock_journal(p_s_sb); |
3593 | } | 3580 | } |
3594 | } | 3581 | } |
3595 | if (journal->j_trans_id == trans_id) { | 3582 | BUG_ON(journal->j_trans_id == trans_id); |
3596 | BUG(); | 3583 | |
3597 | } | ||
3598 | if (commit_now | 3584 | if (commit_now |
3599 | && journal_list_still_alive(p_s_sb, trans_id) | 3585 | && journal_list_still_alive(p_s_sb, trans_id) |
3600 | && wait_on_commit) { | 3586 | && wait_on_commit) { |
@@ -4074,9 +4060,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, | |||
4074 | set_commit_trans_len(commit, journal->j_len); | 4060 | set_commit_trans_len(commit, journal->j_len); |
4075 | 4061 | ||
4076 | /* special check in case all buffers in the journal were marked for not logging */ | 4062 | /* special check in case all buffers in the journal were marked for not logging */ |
4077 | if (journal->j_len == 0) { | 4063 | BUG_ON(journal->j_len == 0); |
4078 | BUG(); | ||
4079 | } | ||
4080 | 4064 | ||
4081 | /* we're about to dirty all the log blocks, mark the description block | 4065 | /* we're about to dirty all the log blocks, mark the description block |
4082 | * dirty now too. Don't mark the commit block dirty until all the | 4066 | * dirty now too. Don't mark the commit block dirty until all the |
@@ -4173,8 +4157,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, | |||
4173 | journal, jl, &jl->j_tail_bh_list); | 4157 | journal, jl, &jl->j_tail_bh_list); |
4174 | lock_kernel(); | 4158 | lock_kernel(); |
4175 | } | 4159 | } |
4176 | if (!list_empty(&jl->j_tail_bh_list)) | 4160 | BUG_ON(!list_empty(&jl->j_tail_bh_list)); |
4177 | BUG(); | ||
4178 | up(&jl->j_commit_lock); | 4161 | up(&jl->j_commit_lock); |
4179 | 4162 | ||
4180 | /* honor the flush wishes from the caller, simple commits can | 4163 | /* honor the flush wishes from the caller, simple commits can |
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c index 16e9cff8f15d..abde1edc2235 100644 --- a/fs/reiserfs/namei.c +++ b/fs/reiserfs/namei.c | |||
@@ -67,8 +67,7 @@ inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de) | |||
67 | { | 67 | { |
68 | struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num; | 68 | struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num; |
69 | 69 | ||
70 | if (de->de_entry_num >= ih_entry_count(de->de_ih)) | 70 | BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih)); |
71 | BUG(); | ||
72 | 71 | ||
73 | de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num); | 72 | de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num); |
74 | de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0); | 73 | de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0); |
@@ -80,8 +79,7 @@ inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de) | |||
80 | // what entry points to | 79 | // what entry points to |
81 | static inline void set_de_object_key(struct reiserfs_dir_entry *de) | 80 | static inline void set_de_object_key(struct reiserfs_dir_entry *de) |
82 | { | 81 | { |
83 | if (de->de_entry_num >= ih_entry_count(de->de_ih)) | 82 | BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih)); |
84 | BUG(); | ||
85 | de->de_dir_id = deh_dir_id(&(de->de_deh[de->de_entry_num])); | 83 | de->de_dir_id = deh_dir_id(&(de->de_deh[de->de_entry_num])); |
86 | de->de_objectid = deh_objectid(&(de->de_deh[de->de_entry_num])); | 84 | de->de_objectid = deh_objectid(&(de->de_deh[de->de_entry_num])); |
87 | } | 85 | } |
@@ -90,8 +88,7 @@ static inline void store_de_entry_key(struct reiserfs_dir_entry *de) | |||
90 | { | 88 | { |
91 | struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num; | 89 | struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num; |
92 | 90 | ||
93 | if (de->de_entry_num >= ih_entry_count(de->de_ih)) | 91 | BUG_ON(de->de_entry_num >= ih_entry_count(de->de_ih)); |
94 | BUG(); | ||
95 | 92 | ||
96 | /* store key of the found entry */ | 93 | /* store key of the found entry */ |
97 | de->de_entry_key.version = KEY_FORMAT_3_5; | 94 | de->de_entry_key.version = KEY_FORMAT_3_5; |
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index 8b9b13127136..5240abe1a709 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -1476,9 +1476,7 @@ static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th, | |||
1476 | int n_block_size = p_s_sb->s_blocksize; | 1476 | int n_block_size = p_s_sb->s_blocksize; |
1477 | int cut_bytes; | 1477 | int cut_bytes; |
1478 | BUG_ON(!th->t_trans_id); | 1478 | BUG_ON(!th->t_trans_id); |
1479 | 1479 | BUG_ON(n_new_file_size != p_s_inode->i_size); | |
1480 | if (n_new_file_size != p_s_inode->i_size) | ||
1481 | BUG(); | ||
1482 | 1480 | ||
1483 | /* the page being sent in could be NULL if there was an i/o error | 1481 | /* the page being sent in could be NULL if there was an i/o error |
1484 | ** reading in the last block. The user will hit problems trying to | 1482 | ** reading in the last block. The user will hit problems trying to |