mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Genjian <zhanggenjian123@gmail.com>,
	clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Genjian Zhang <zhanggenjian@kylinos.cn>,
	k2ci <kernel-bot@kylinos.cn>
Subject: Re: [PATCH] btrfs: fix uninitialized variable warning
Date: Fri, 24 Mar 2023 03:29:04 +0100	[thread overview]
Message-ID: <20230324022904.GD10580@twin.jikos.cz> (raw)
In-Reply-To: <78422b96-52ed-b48a-27d0-1cfaa89a6608@gmx.com>

On Fri, Mar 24, 2023 at 10:24:55AM +0800, Qu Wenruo wrote:
> On 2023/3/24 10:08, Genjian wrote:
> > From: Genjian Zhang <zhanggenjian@kylinos.cn>
> > 
> > compiler warning:
> 
> Compiler version please.
> 
> > 
> > ../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;
> >        |      ^~~~~~~~~
> > 
> > Initialize the uninitialized variables.
> > 
> > Reported-by: k2ci <kernel-bot@kylinos.cn>
> > Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
> > ---
> >   fs/btrfs/send.c    | 2 +-
> >   fs/btrfs/volumes.c | 2 +-
> >   2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> > index e5c963bb873d..af2e153543a5 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;
> 
> IIRC this is not my first time explaining why this is a false alert.
> 
> Thus please report your compiler version first.

This is probably because of the -Wmaybe-uninitialized we enabled, on
some combination of architecture and compiler. While I'm also interested
in the compiler and version we need to fix the warnings before 6.3 final.
We'd be gettting the warnings and reports/patches, which is wasting
peoples' time, it's not a big deal to initialize the variables. But
still I also want to know which version reports that.

  reply	other threads:[~2023-03-24  2:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24  2:08 Genjian
2023-03-24  2:24 ` Qu Wenruo
2023-03-24  2:29   ` David Sterba [this message]
2023-03-24  3:05     ` genjian zhang
2023-03-24  4:24       ` Qu Wenruo
2023-03-24  5:47         ` genjian zhang
2023-04-06 19:12 ` David Sterba
2023-04-23  9:21   ` genjian zhang
  -- strict thread matches above, loose matches on Subject: below --
2011-06-03  1:00 linux-next: build warning from Linus' tree Stephen Rothwell
2011-06-03 14:50 ` [PATCH] btrfs: fix uninitialized variable warning David Sterba
2011-06-03 14:56   ` Chris Mason

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=20230324022904.GD10580@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-bot@kylinos.cn \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    --cc=zhanggenjian123@gmail.com \
    --cc=zhanggenjian@kylinos.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®