Skip to contentSkip to conversation

btrfs: avoid spurious -Wmaybe-uninitialized warnings in do_remap_reloc_trans()

PATCH In review Mark Harmstone 2 participants 2 messages Jan 20 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: avoid spurious -Wmaybe-uninitialized warnings in do_remap_reloc_trans()

find_next_identity_remap() sets the values of the start and length pointers if it returns 0. Some versions of GCC are unable to analyse this properly and give spurious -Wmaybe-uninitialized warnings, so initialize the values in do_remap_reloc_trans() to avoid this.

---
 fs/btrfs/relocation.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/relocation.c +2 -1
index 065db3f7840e..da4749d6bfa0 100644
@@ -4940,7 +4940,8 @@ static int do_remap_reloc_trans(struct btrfs_fs_info *fs_info,
 	struct btrfs_root *extent_root;
 	struct btrfs_key ins;
 	struct btrfs_block_group *dest_bg = NULL;
-	u64 start, remap_length, length, new_addr, min_size;
+	u64 start = 0, remap_length = 0;
+	u64 length, new_addr, min_size;
 	int ret;
 	bool no_more = false;
 	bool is_data = (src_bg->flags & BTRFS_BLOCK_GROUP_DATA);
Signature · 1 line
2.51.2
#1 lore raw
Quoted 6 lines · Mark Harmstone

find_next_identity_remap() sets the values of the start and length pointers if it returns 0. Some versions of GCC are unable to analyse this properly and give spurious -Wmaybe-uninitialized warnings, so initialize the values in do_remap_reloc_trans() to avoid this.

Folded to for-next patch, please also mention to which patch it's supposed to go to so I don't have to guess.