Convert various if() BUG(); to BUG_ON();
PATCH 1/1 Convert various if() BUG(); to BUG_ON();
This patch converts the remaining manual tests which call BUG() directly after a test to just use BUG_ON() instead.
It is a simple inplace change using Coccinelle'sBUG_ON.cocci test.
Signed-off-by Chris Samuel <[email protected]>
--- fs/btrfs/ctree.c | 7 ++----- fs/btrfs/print-tree.c | 8 ++------ fs/btrfs/tree-log.c | 4 +--- fs/btrfs/volumes.c | 3 +-- 4 files changed, 6 insertions(+), 16 deletions(-)
fs/btrfs/ctree.c +2 -5
@@ -1178,9 +1178,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, }/* double check we haven't messed things up */ check_block (root, path, level); -if (orig_ptr != -btrfs_node_blockptr (path->nodes[level], path->slots[level])) -BUG (); +BUG_ON (orig_ptr !=btrfs_node_blockptr (path->nodes[level], path->slots[level])); enospc:if (right) {btrfs_tree_unlock (right);
@@ -2137,8 +2135,7 @@ static int insert_ptr(struct btrfs_trans_handle *trans, struct btrfs_root lower = path->nodes[level]; nritems =btrfs_header_nritems (lower);BUG_ON (slot > nritems); -if (nritems ==BTRFS_NODEPTRS_PER_BLOCK (root)) -BUG (); +BUG_ON (nritems ==BTRFS_NODEPTRS_PER_BLOCK (root));if (slot != nritems) { memmove_extent_buffer(lower, btrfs_node_key_ptr_offset(slot + 1),
fs/btrfs/print-tree.c +2 -6
@@ -325,12 +325,8 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)btrfs_node_blockptr (c, i),btrfs_level_size (root, level -1 ), btrfs_node_ptr_generation(c, i)); -if (btrfs_is_leaf (next) && - level !=1 ) -BUG (); -if (btrfs_header_level (next) != - level -1 ) -BUG (); +BUG_ON (btrfs_is_leaf (next) && level !=1 ); +BUG_ON (btrfs_header_level (next) != level -1 );btrfs_print_tree (root, next);free_extent_buffer (next); }
fs/btrfs/tree-log.c +1 -3
@@ -375,9 +375,7 @@ insert: item_size - found_size);BUG_ON (ret); } - }else if (ret) { -BUG (); - } + }else BUG_ON (ret); dst_ptr =btrfs_item_ptr_offset (path->nodes[0 ], path->slots[0 ]);
fs/btrfs/volumes.c +1 -2
@@ -1860,8 +1860,7 @@ again: found_key.offset);if (ret == -ENOSPC ) failed++; -else if (ret) -BUG (); +else BUG_ON (ret); }if (found_key.offset ==0 )
Signature · 4 lines
1.7.0.4 -- Chris Samuel : http://www.csamuel.org/ : Melbourne, VIC