Skip to contentSkip to conversation

btrfs-progs: trivial code style fix in root-tree.c

PATCH In review Wang Sheng-Hui 2 participants 5 messages Aug 16, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: trivial code style fix in root-tree.c

Add code indent to the bad styled statements.

---
 root-tree.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
root-tree.c +4 -6
index 782472c..39cfef6 100644
@@ -182,12 +182,10 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 	if (ret < 0)
 		goto out;
 	if (ret) {
-btrfs_print_leaf(root, path->nodes[0]);
-printk("failed to del %llu %u %llu\n",
-	(unsigned long long)key->objectid,
-	key->type,
-	(unsigned long long)key->offset);
-
+		btrfs_print_leaf(root, path->nodes[0]);
+		printk("failed to del %llu %u %llu\n",
+			(unsigned long long)key->objectid, key->type,
+			(unsigned long long)key->offset);
 	}
 	BUG_ON(ret != 0);
 	leaf = path->nodes[0];
Signature · 1 line
1.7.1
#1 lore raw
Quoted 12 lines · Wang Sheng-Hui

Add code indent to the bad styled statements.

---
 root-tree.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
root-tree.c +0 -0
index 782472c..39cfef6 100644

root-tree.c int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, · line 190

Quoted 9 lines
root-tree.c +0 -6
@@ -182,12 +182,10 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 	if (ret < 0)
 		goto out;
 	if (ret) {
-btrfs_print_leaf(root, path->nodes[0]);
-printk("failed to del %llu %u %llu\n",
-	(unsigned long long)key->objectid,
-	key->type,
-	(unsigned long long)key->offset);
-

I guess Alexander intentionally put in the bad indentation to remind him to remove this code before submitting the patch :)

Quoted 7 lines
root-tree.c +4 -0
+		btrfs_print_leaf(root, path->nodes[0]);
+		printk("failed to del %llu %u %llu\n",
+			(unsigned long long)key->objectid, key->type,
+			(unsigned long long)key->offset);
 	}
 	BUG_ON(ret != 0);
 	leaf = path->nodes[0];
#2 lore raw
Quoted 27 lines · Arne Jansen
Quoted 12 lines · Wang Sheng-Hui

Add code indent to the bad styled statements.

---
 root-tree.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
root-tree.c +0 -0
index 782472c..39cfef6 100644

root-tree.c int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, · line 190

Quoted 9 lines
root-tree.c +0 -6
@@ -182,12 +182,10 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 	if (ret < 0)
 		goto out;
 	if (ret) {
-btrfs_print_leaf(root, path->nodes[0]);
-printk("failed to del %llu %u %llu\n",
-	(unsigned long long)key->objectid,
-	key->type,
-	(unsigned long long)key->offset);
-

I guess Alexander intentionally put in the bad indentation to remind him to remove this code before submitting the patch :)

Quoted 5 lines

root-tree.c int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, · line 189

Quoted 5 lines
root-tree.c +4 -0
+		btrfs_print_leaf(root, path->nodes[0]);
+		printk("failed to del %llu %u %llu\n",
+			(unsigned long long)key->objectid, key->type,
+			(unsigned long long)key->offset);
 	}

When I saw the BUG_ON, I wonder do we still need the above branch statement. It looks just to be helpful for debug - give out some info, right?

Quoted 3 lines
Quoted 2 lines
root-tree.c +0 -0
 	BUG_ON(ret != 0);
 	leaf = path->nodes[0];
#3 lore raw
Quoted 28 lines · Wang Sheng-Hui
Quoted 27 lines · Arne Jansen
Quoted 12 lines · Wang Sheng-Hui

Add code indent to the bad styled statements.

---
 root-tree.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
root-tree.c +0 -0
index 782472c..39cfef6 100644

root-tree.c int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, · line 190

Quoted 9 lines
root-tree.c +0 -6
@@ -182,12 +182,10 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 	if (ret < 0)
 		goto out;
 	if (ret) {
-btrfs_print_leaf(root, path->nodes[0]);
-printk("failed to del %llu %u %llu\n",
-	(unsigned long long)key->objectid,
-	key->type,
-	(unsigned long long)key->offset);
-

I guess Alexander intentionally put in the bad indentation to remind him to remove this code before submitting the patch :)

Quoted 8 lines
Quoted 5 lines

root-tree.c int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, · line 189

Quoted 5 lines
root-tree.c +4 -0
+		btrfs_print_leaf(root, path->nodes[0]);
+		printk("failed to del %llu %u %llu\n",
+			(unsigned long long)key->objectid, key->type,
+			(unsigned long long)key->offset);
 	}

When I saw the BUG_ON, I wonder do we still need the above branch statement. It looks just to be helpful for debug - give out some info, right?

Yes. So either we delete it completely or we move the BUG_ON into the block as a BUG_ON(1) and add a "Btrfs: "-prefix to the printk.
On the other hand, I just saw this is progs, so I think it can just be deleted.

Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
root-tree.c +0 -0
 	BUG_ON(ret != 0);
 	leaf = path->nodes[0];
#4 lore raw
Quoted 38 lines · Arne Jansen
Quoted 28 lines · Wang Sheng-Hui
Quoted 27 lines · Arne Jansen
Quoted 12 lines · Wang Sheng-Hui

Add code indent to the bad styled statements.

---
 root-tree.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
root-tree.c +0 -0
index 782472c..39cfef6 100644

root-tree.c int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, · line 190

Quoted 9 lines
root-tree.c +0 -6
@@ -182,12 +182,10 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 	if (ret < 0)
 		goto out;
 	if (ret) {
-btrfs_print_leaf(root, path->nodes[0]);
-printk("failed to del %llu %u %llu\n",
-	(unsigned long long)key->objectid,
-	key->type,
-	(unsigned long long)key->offset);
-

I guess Alexander intentionally put in the bad indentation to remind him to remove this code before submitting the patch :)

Quoted 8 lines
Quoted 5 lines

root-tree.c int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, · line 189

Quoted 5 lines
root-tree.c +4 -0
+		btrfs_print_leaf(root, path->nodes[0]);
+		printk("failed to del %llu %u %llu\n",
+			(unsigned long long)key->objectid, key->type,
+			(unsigned long long)key->offset);
 	}

When I saw the BUG_ON, I wonder do we still need the above branch statement. It looks just to be helpful for debug - give out some info, right?

Quoted 12 lines

Yes. So either we delete it completely or we move the BUG_ON into the block as a BUG_ON(1) and add a "Btrfs: "-prefix to the printk.
On the other hand, I just saw this is progs, so I think it can just be deleted.

Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
root-tree.c +0 -0
 	BUG_ON(ret != 0);
 	leaf = path->nodes[0];

Patch regenerated. Please check it. Thanks,

Quoted 1 line

From 2150cb3a3f75416b56a5eb9311fd0d4aa5aaaed5 Mon Sep 17 00:00:00 2001

From: Wang Sheng-Hui <[email protected]>
Date: Thu, 16 Aug 2012 22:23:07 +0800
Subject: [PATCH] btrfs-progs: code cleanup for root-tree.c/btrfs_del_root

Remove the redundant if check on the condition ret > 0. Leave BUG_ON check here.

---
 root-tree.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
root-tree.c +0 -8
index 782472c..4578514 100644
@@ -181,14 +181,6 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 	ret = btrfs_search_slot(trans, root, key, path, -1, 1);
 	if (ret < 0)
 		goto out;
-	if (ret) {
-btrfs_print_leaf(root, path->nodes[0]);
-printk("failed to del %llu %u %llu\n",
-	(unsigned long long)key->objectid,
-	key->type,
-	(unsigned long long)key->offset);
-
-	}
 	BUG_ON(ret != 0);
 	leaf = path->nodes[0];
 	ri = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_item);
Signature · 1 line
1.7.1