All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Yugui <wangyugui@e16-tech.com>
To: trix@redhat.com
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: initialize variable cancel
Date: Tue, 25 Jan 2022 13:04:30 +0800	[thread overview]
Message-ID: <20220125130429.75C1.409509F4@e16-tech.com> (raw)
In-Reply-To: <20220121134522.832207-1-trix@redhat.com>

Hi,

Mabye we should enable '-Wmaybe-uninitialized' for btrfs 'make W=1'.

There is another warning  reproted by '-Wmaybe-uninitialized' 
in btrfs misc-next.

fs/btrfs/zoned.c:273:28: warning: ‘zno’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   memcpy(zinfo->zone_cache + zno, zones,
                            ^

diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
index cec88a6..f1052ce 100644
--- a/fs/btrfs/Makefile
+++ b/fs/btrfs/Makefile
@@ -2,6 +2,7 @@
 
 # Subset of W=1 warnings
 subdir-ccflags-y += -Wextra -Wunused -Wno-unused-parameter
+subdir-ccflags-y += -Wmaybe-uninitialized
 subdir-ccflags-y += -Wmissing-declarations
 subdir-ccflags-y += -Wmissing-format-attribute
 subdir-ccflags-y += -Wmissing-prototypes

Best Regards
Wang Yugui (wangyugui@e16-tech.com)
2022/01/25

> From: Tom Rix <trix@redhat.com>
> 
> Clang static analysis reports this problem
> ioctl.c:3333:8: warning: 3rd function call argument is an
>   uninitialized value
>     ret = exclop_start_or_cancel_reloc(fs_info,
> 
> cancel is only set in one branch of an if-check and is
> always used.  So initialize to false.
> 
> Fixes: 1a15eb724aae ("btrfs: use btrfs_get_dev_args_from_path in dev removal ioctls")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>  fs/btrfs/ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 190ad8af4f45a..26e82379747f8 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3308,7 +3308,7 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg)
>  	struct block_device *bdev = NULL;
>  	fmode_t mode;
>  	int ret;
> -	bool cancel;
> +	bool cancel = false;
>  
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
> -- 
> 2.26.3



  parent reply	other threads:[~2022-01-25  5:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21 13:45 [PATCH] btrfs: initialize variable cancel trix
2022-01-21 15:40 ` Filipe Manana
2022-01-21 21:50 ` Anand Jain
2022-01-24 19:49 ` David Sterba
2022-01-25  5:04 ` Wang Yugui [this message]
2022-01-25  8:30   ` Johannes Thumshirn
2022-01-25 13:27     ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220125130429.75C1.409509F4@e16-tech.com \
    --to=wangyugui@e16-tech.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.