Skip to content

Commit 8ba7d5f

Browse files
Genjian Zhangkdave
authored andcommitted
btrfs: fix uninitialized variable warnings
There are some warnings on older compilers (gcc 10, 7) or non-x86_64 architectures (aarch64). As btrfs wants to enable -Wmaybe-uninitialized by default, fix the warnings even though it's not necessary on recent compilers (gcc 12+). ../fs/btrfs/volumes.c: In function ‘btrfs_init_new_device’: ../fs/btrfs/volumes.c:2703:3: error: ‘seed_devices’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 2703 | btrfs_setup_sprout(fs_info, seed_devices); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../fs/btrfs/send.c: In function ‘get_cur_inode_state’: ../include/linux/compiler.h:70:32: error: ‘right_gen’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 70 | (__if_trace.miss_hit[1]++,1) : \ | ^ ../fs/btrfs/send.c:1878:6: note: ‘right_gen’ was declared here 1878 | u64 right_gen; | ^~~~~~~~~ Reported-by: k2ci <[email protected]> Signed-off-by: Genjian Zhang <[email protected]> Reviewed-by: David Sterba <[email protected]> [ update changelog ] Signed-off-by: David Sterba <[email protected]>
1 parent 5d3e4f1 commit 8ba7d5f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/btrfs/send.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,7 @@ static int get_cur_inode_state(struct send_ctx *sctx, u64 ino, u64 gen,
18751875
int left_ret;
18761876
int right_ret;
18771877
u64 left_gen;
1878-
u64 right_gen;
1878+
u64 right_gen = 0;
18791879
struct btrfs_inode_info info;
18801880

18811881
ret = get_inode_info(sctx->send_root, ino, &info);

fs/btrfs/volumes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
26172617
struct block_device *bdev;
26182618
struct super_block *sb = fs_info->sb;
26192619
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
2620-
struct btrfs_fs_devices *seed_devices;
2620+
struct btrfs_fs_devices *seed_devices = NULL;
26212621
u64 orig_super_total_bytes;
26222622
u64 orig_super_num_devices;
26232623
int ret = 0;

0 commit comments

Comments
 (0)