Messages in this thread Patch in this message | | | Date | Mon, 10 Jul 2023 21:25:23 +0200 | From | "Arnd Bergmann" <> | Subject | Re: [PATCH 1/2] btrfs: avoid Wmaybe-uninitialized warnings |
| |
On Mon, Jul 10, 2023, at 21:12, Arnd Bergmann wrote: > > building for arm32 (see below), I get maybe 20 failed builds, but > for x86 this is lower, maybe 2. I had attempted to work around > each one of the ones I saw, but ended up with a huge patch to > cover all architectures and compilers in random versions.
FWIW, this is the last version of my workaround patch from January before I gave up on trying to fix all the btrfs warnings on uninitialized variables.
Arnd
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index db79e6b0a693f..ab2e54930ee5f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5656,7 +5656,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) struct inode *inode; struct btrfs_root *root = BTRFS_I(dir)->root; struct btrfs_root *sub_root = root; - struct btrfs_key location; + struct btrfs_key location = {}; u8 di_type = 0; int ret = 0; diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index ba769a1eb87ab..79e0c3a14c7fd 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1730,7 +1730,7 @@ static noinline int btrfs_ioctl_tree_search(struct inode *inode, void __user *argp) { struct btrfs_ioctl_search_args __user *uargs = argp; - struct btrfs_ioctl_search_key sk; + struct btrfs_ioctl_search_key sk = {}; int ret; size_t buf_size; @@ -1760,7 +1760,7 @@ static noinline int btrfs_ioctl_tree_search_v2(struct inode *inode, void __user *argp) { struct btrfs_ioctl_search_args_v2 __user *uarg = argp; - struct btrfs_ioctl_search_args_v2 args; + struct btrfs_ioctl_search_args_v2 args = {}; int ret; size_t buf_size; const size_t buf_limit = SZ_16M; @@ -2971,7 +2971,7 @@ static void get_block_group_info(struct list_head *groups_list, static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info, void __user *arg) { - struct btrfs_ioctl_space_args space_args; + struct btrfs_ioctl_space_args space_args = {}; struct btrfs_ioctl_space_info space; struct btrfs_ioctl_space_info *dest; struct btrfs_ioctl_space_info *dest_orig; @@ -3132,7 +3132,7 @@ static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root, static noinline long btrfs_ioctl_wait_sync(struct btrfs_fs_info *fs_info, void __user *argp) { - u64 transid; + u64 transid = 0; if (argp) { if (copy_from_user(&transid, argp, sizeof(transid))) @@ -4106,7 +4106,7 @@ static int btrfs_ioctl_set_fslabel(struct file *file, void __user *arg) struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_super_block *super_block = fs_info->super_copy; struct btrfs_trans_handle *trans; - char label[BTRFS_LABEL_SIZE]; + char label[BTRFS_LABEL_SIZE] = {}; int ret; if (!capable(CAP_SYS_ADMIN)) @@ -4248,7 +4248,7 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg) struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_super_block *super_block = fs_info->super_copy; - struct btrfs_ioctl_feature_flags flags[2]; + struct btrfs_ioctl_feature_flags flags[2] = {}; struct btrfs_trans_handle *trans; u64 newflags; int ret; @@ -4320,7 +4320,7 @@ static int _btrfs_ioctl_send(struct inode *inode, void __user *argp, bool compat if (compat) { #if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT) - struct btrfs_ioctl_send_args_32 args32; + struct btrfs_ioctl_send_args_32 args32 = {}; ret = copy_from_user(&args32, argp, sizeof(args32)); if (ret) @@ -4369,7 +4369,7 @@ static int btrfs_ioctl_encoded_read(struct file *file, void __user *argp, if (compat) { #if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT) - struct btrfs_ioctl_encoded_io_args_32 args32; + struct btrfs_ioctl_encoded_io_args_32 args32 = {}; copy_end = offsetofend(struct btrfs_ioctl_encoded_io_args_32, flags); @@ -4433,7 +4433,7 @@ static int btrfs_ioctl_encoded_read(struct file *file, void __user *argp, static int btrfs_ioctl_encoded_write(struct file *file, void __user *argp, bool compat) { - struct btrfs_ioctl_encoded_io_args args; + struct btrfs_ioctl_encoded_io_args args = {}; struct iovec iovstack[UIO_FASTIOV]; struct iovec *iov = iovstack; struct iov_iter iter; @@ -4453,7 +4453,7 @@ static int btrfs_ioctl_encoded_write(struct file *file, void __user *argp, bool if (compat) { #if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT) - struct btrfs_ioctl_encoded_io_args_32 args32; + struct btrfs_ioctl_encoded_io_args_32 args32 = {}; if (copy_from_user(&args32, argp, sizeof(args32))) { ret = -EFAULT; diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index f41da7ac360d8..e93583f3f928b 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -4362,6 +4362,10 @@ int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans, } node = blocks->blocks[level].rb_node; + if (!node) { + spin_unlock(&blocks->lock); + goto out; + } while (node) { block = rb_entry(node, struct btrfs_qgroup_swapped_block, node); if (block->subvol_bytenr < subvol_eb->start) { diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index e5c963bb873db..af2e153543a5c 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -1875,7 +1875,7 @@ static int get_cur_inode_state(struct send_ctx *sctx, u64 ino, u64 gen, int left_ret; int right_ret; u64 left_gen; - u64 right_gen; + u64 right_gen = 0; struct btrfs_inode_info info; ret = get_inode_info(sctx->send_root, ino, &info); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index de96d26f81f64..43b200102d1e6 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2618,7 +2618,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path struct block_device *bdev; struct super_block *sb = fs_info->sb; struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; - struct btrfs_fs_devices *seed_devices; + struct btrfs_fs_devices *seed_devices = NULL; u64 orig_super_total_bytes; u64 orig_super_num_devices; int ret = 0;
| |