Skip to contentSkip to conversation

btrfs: initialize return variable

PATCH In review [email protected] 2 participants 2 messages Apr 30, 2021 – May 3, 2021 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: initialize return variable

From: Tom Rix <[email protected]>

Static analysis reports this problem free-space-cache.c:3965:2: warning: Undefined or garbage value returned
return ret;
^~~~~~~~~~

ret is set in the node handling loop.
Treat doing nothing as a success and initialize ret to 0.

---
 fs/btrfs/free-space-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/free-space-cache.c +1 -1
index e54466fc101f..4806295116d8 100644
@@ -3949,7 +3949,7 @@ static int cleanup_free_space_cache_v1(struct btrfs_fs_info *fs_info,
 {
 	struct btrfs_block_group *block_group;
 	struct rb_node *node;
-	int ret;
+	int ret = 0;
 
 	btrfs_info(fs_info, "cleaning free space cache v1");
 
Signature · 1 line
2.26.3
#1 lore raw
Quoted 9 lines · On Fri, Apr 30, 2021 at 11:06:55AM -0700, [email protected] wrote:

From: Tom Rix <[email protected]>

Static analysis reports this problem free-space-cache.c:3965:2: warning: Undefined or garbage value returned
return ret;
^~~~~~~~~~

ret is set in the node handling loop.
Treat doing nothing as a success and initialize ret to 0.

Right, though it's unlikely the loop won't run at least once, having the ret initialized is safe. Patch added to misc-next, thanks.