Skip to contentSkip to conversation

btrfs: zoned: Remove redundant initialization of to_add

PATCH In review Jiapeng Chong 3 participants 3 messages Jan 21, 2022 – Jan 24, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 btrfs: zoned: Remove redundant initialization of to_add

to_add is being initialized to len but this is never read as to_add is overwritten later on. Remove the redundant initialization.

Cleans up the following clang-analyzer warning:

fs/btrfs/extent-tree.c:2769:8: warning: Value stored to 'to_add' during its initialization is never read [clang-analyzer-deadcode.DeadStores].

---
Changes in v2:
-"to_add" is define within the if (!global_rsv->full) branch.

 fs/btrfs/extent-tree.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/btrfs/extent-tree.c +2 -4
index d89273c4b6b8..8e91adbf352e 100644
@@ -2766,12 +2766,10 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
 		spin_unlock(&cache->lock);
 		if (!readonly && return_free_space &&
 		    global_rsv->space_info == space_info) {
-			u64 to_add = len;
-
 			spin_lock(&global_rsv->lock);
 			if (!global_rsv->full) {
-				to_add = min(len, global_rsv->size -
-					     global_rsv->reserved);
+				u64 to_add = min(len, global_rsv->size -
+						 global_rsv->reserved);
 				global_rsv->reserved += to_add;
 				btrfs_space_info_update_bytes_may_use(fs_info,
 						space_info, to_add);
Signature · 1 line
2.20.1.7.g153144c
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Jiapeng Chong

to_add is being initialized to len but this is never read as to_add is overwritten later on. Remove the redundant initialization.

Cleans up the following clang-analyzer warning:

fs/btrfs/extent-tree.c:2769:8: warning: Value stored to 'to_add' during its initialization is never read [clang-analyzer-deadcode.DeadStores].

#2 lore raw
In reply to Jiapeng Chong
Quoted 11 lines · Jiapeng Chong

to_add is being initialized to len but this is never read as to_add is overwritten later on. Remove the redundant initialization.

Cleans up the following clang-analyzer warning:

fs/btrfs/extent-tree.c:2769:8: warning: Value stored to 'to_add' during its initialization is never read [clang-analyzer-deadcode.DeadStores].

Added to misc-next, thanks.