Skip to contentSkip to conversation

btrfs: Remove redundant assignment of variable ret

PATCH In review Colin King 2 participants 2 messages Oct 7, 2021 – Oct 8, 2021

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 btrfs: Remove redundant assignment of variable ret

From: Colin Ian King <[email protected]>

The variable ret is being assigned a value that is never read, it is updated later on with a different value. The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 fs/btrfs/free-space-cache.c | 2 --
 1 file changed, 2 deletions(-)
fs/btrfs/free-space-cache.c +0 -2
index 8ea04582e34b..2a6d02971357 100644
@@ -735,8 +735,6 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
 		return 0;
 	}
 
-	ret = -1;
-
 	leaf = path->nodes[0];
 	header = btrfs_item_ptr(leaf, path->slots[0],
 				struct btrfs_free_space_header);
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Colin King

From: Colin Ian King <[email protected]>

The variable ret is being assigned a value that is never read, it is updated later on with a different value. The assignment is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
  fs/btrfs/free-space-cache.c | 2 --
  1 file changed, 2 deletions(-)
fs/btrfs/free-space-cache.c +0 -0
index 8ea04582e34b..2a6d02971357 100644

fs/btrfs/free-space-cache.c static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode, · line 739

Quoted 5 lines
fs/btrfs/free-space-cache.c +0 -2
@@ -735,8 +735,6 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
  		return 0;
  	}
 
-	ret = -1;
-

Essentially we had goto out; when the inode generation check failed few lines below. However, the commit a67509c30079 (Btrfs: add an io_ctl struct and helpers for dealing with the space cache) replaced it with return 0; and then ret = -1 did not make any sense.

Thanks, Anand

Quoted 4 lines
fs/btrfs/free-space-cache.c +0 -0
  	leaf = path->nodes[0];
  	header = btrfs_item_ptr(leaf, path->slots[0],
  				struct btrfs_free_space_header);