[PATCH 8/8] btrfs: cleanup: use BUG_ON when appropriate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Generated by spatch:
<Smpl>
@r@
expression E;
@@
- if(E)
- BUG();
+ BUG_ON(E);
</Smpl>

Signed-off-by: David Sterba <dsterba@xxxxxxx>
---
 fs/btrfs/ctree.c      |    8 +++-----
 fs/btrfs/print-tree.c |    8 ++------
 fs/btrfs/volumes.c    |    4 ++--
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 011cab3..540ad34 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1068,9 +1068,8 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
 		}
 	}
 	/* double check we haven't messed things up */
-	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);
@@ -2138,8 +2137,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),
diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index 5138c2a..2528841 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -326,12 +326,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);
 	}
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 25ca81d..fe0a5f2 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2040,8 +2040,8 @@ again:
 						   found_key.offset);
 			if (ret == -ENOSPC)
 				failed++;
-			else if (ret)
-				BUG();
+			else
+				BUG_ON(ret);
 		}
 
 		if (found_key.offset == 0)
-- 
1.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux