Skip to contentSkip to conversation

Btrfs: Remove useless condition

PATCH In review Jaswinder Singh Rajput 4 participants 4 messages Sep 12, 2010 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: Remove useless condition

if (ret) is useless as it will be never NULL as in previous statement we are setting ret = prev for !ret

---
 fs/btrfs/ordered-data.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/btrfs/ordered-data.c +1 -2
index e56c72b..7b04008 100644
@@ -154,8 +154,7 @@ static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree,
 	ret = __tree_search(root, file_offset, &prev);
 	if (!ret)
 		ret = prev;
-	if (ret)
-		tree->last = ret;
+	tree->last = ret;
 	return ret;
 }
 
Signature · 1 line
1.7.2.2
#1 lore raw
Quoted 3 lines · Jaswinder Singh Rajput

if (ret) is useless as it will be never NULL as in previous statement we are setting ret = prev for !ret

If there is no match and no extent below the given file offset, `prev' will be NULL as well, no?

So the check is not useless, it prevents throwing out a cached success in case of a lookup failure.

Quoted 31 lines
---
 fs/btrfs/ordered-data.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
fs/btrfs/ordered-data.c +1 -2
index e56c72b..7b04008 100644
@@ -154,8 +154,7 @@ static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree,
 	ret = __tree_search(root, file_offset, &prev);
 	if (!ret)
 		ret = prev;
-	if (ret)
-		tree->last = ret;
+	tree->last = ret;
 	return ret;
 }
 
Signature · 9 lines
1.7.2.2



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#2 lore raw

Hello,

Quoted 11 lines · Johannes Weiner
Quoted 3 lines · Jaswinder Singh Rajput

if (ret) is useless as it will be never NULL as in previous statement we are setting ret = prev for !ret

If there is no match and no extent below the given file offset, `prev' will be NULL as well, no?

So the check is not useless, it prevents throwing out a cached success in case of a lookup failure.

Got it !!

Thanks,
--
Jaswinder Singh.

#3 lore raw
Quoted 8 lines · Jaswinder Singh Rajput

Hello,

Quoted 5 lines · Johannes Weiner
Quoted 3 lines · Jaswinder Singh Rajput

if (ret) is useless as it will be never NULL as in previous statement we are setting ret = prev for !ret

Quoted 9 lines
Quoted 6 lines

If there is no match and no extent below the given file offset, `prev' will be NULL as well, no?

So the check is not useless, it prevents throwing out a cached success in case of a lookup failure.

Got it !!

Wouldn't it be clearer and easier to read if prev was checked directly instead of checking ret after it becomes the same as prev?