From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning
Date: Tue, 1 Aug 2017 16:23:47 -0600 [thread overview]
Message-ID: <20170801222347.GF20061@linux.intel.com> (raw)
In-Reply-To: <20170801144534.2a1e1def29e68eb6c83e203c@linux-foundation.org>
On Tue, Aug 01, 2017 at 02:45:34PM -0700, Andrew Morton wrote:
> On Tue, 1 Aug 2017 13:48:48 +0200 Arnd Bergmann <arnd@arndb.de> wrote:
>
> > Removing the btt_rw_page/pmem_rw_page functions had a surprising
> > side-effect of introducing a false-positive warning in another
> > function, due to changed inlining decisions in gcc:
> >
> > In file included from drivers/nvdimm/pmem.c:36:0:
> > drivers/nvdimm/pmem.c: In function 'pmem_make_request':
> > drivers/nvdimm/nd.h:407:2: error: 'start' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > drivers/nvdimm/pmem.c:174:16: note: 'start' was declared here
> > In file included from drivers/nvdimm/btt.c:27:0:
> > drivers/nvdimm/btt.c: In function 'btt_make_request':
> > drivers/nvdimm/nd.h:407:2: error: 'start' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > drivers/nvdimm/btt.c:1202:16: note: 'start' was declared here
> >
> > The problem is that gcc fails to track the value of the 'do_acct'
> > variable here and has to read it back from stack, but it does
> > remember that 'start' may be uninitialized sometimes.
> >
> > This shuts up the warning by making nd_iostat_start() always
> > initialize the 'start' variable. In those cases that gcc successfully
> > tracks the state of the variable, this will have no effect.
> >
> > ...
> >
> > --- a/drivers/nvdimm/nd.h
> > +++ b/drivers/nvdimm/nd.h
> > @@ -392,8 +392,10 @@ static inline bool nd_iostat_start(struct bio *bio, unsigned long *start)
> > {
> > struct gendisk *disk = bio->bi_bdev->bd_disk;
> >
> > - if (!blk_queue_io_stat(disk->queue))
> > + if (!blk_queue_io_stat(disk->queue)) {
> > + *start = 0;
> > return false;
> > + }
> >
> > *start = jiffies;
> > generic_start_io_acct(bio_data_dir(bio),
>
> Well that's sad.
>
> The future of btt-remove-btt_rw_page.patch and friends is shrouded in
> mystery, but if we proceed that way then yes, I guess we'll need to
> work around such gcc glitches.
>
> But let's not leave apparently-unneeded code in place without telling
> people why it is in fact needed?
Maybe it's just cleaner to initialize 'start' in all the callers, so we don't
have a mysterious line and have to remember why it's there / comment it?
I'll throw a patch like that in my series if/when I repost.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Ross Zwisler <ross.zwisler@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Christoph Hellwig <hch@infradead.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Toshi Kani <toshi.kani@hpe.com>,
Johannes Thumshirn <jthumshirn@suse.de>,
linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning
Date: Tue, 1 Aug 2017 16:23:47 -0600 [thread overview]
Message-ID: <20170801222347.GF20061@linux.intel.com> (raw)
In-Reply-To: <20170801144534.2a1e1def29e68eb6c83e203c@linux-foundation.org>
On Tue, Aug 01, 2017 at 02:45:34PM -0700, Andrew Morton wrote:
> On Tue, 1 Aug 2017 13:48:48 +0200 Arnd Bergmann <arnd@arndb.de> wrote:
>
> > Removing the btt_rw_page/pmem_rw_page functions had a surprising
> > side-effect of introducing a false-positive warning in another
> > function, due to changed inlining decisions in gcc:
> >
> > In file included from drivers/nvdimm/pmem.c:36:0:
> > drivers/nvdimm/pmem.c: In function 'pmem_make_request':
> > drivers/nvdimm/nd.h:407:2: error: 'start' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > drivers/nvdimm/pmem.c:174:16: note: 'start' was declared here
> > In file included from drivers/nvdimm/btt.c:27:0:
> > drivers/nvdimm/btt.c: In function 'btt_make_request':
> > drivers/nvdimm/nd.h:407:2: error: 'start' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > drivers/nvdimm/btt.c:1202:16: note: 'start' was declared here
> >
> > The problem is that gcc fails to track the value of the 'do_acct'
> > variable here and has to read it back from stack, but it does
> > remember that 'start' may be uninitialized sometimes.
> >
> > This shuts up the warning by making nd_iostat_start() always
> > initialize the 'start' variable. In those cases that gcc successfully
> > tracks the state of the variable, this will have no effect.
> >
> > ...
> >
> > --- a/drivers/nvdimm/nd.h
> > +++ b/drivers/nvdimm/nd.h
> > @@ -392,8 +392,10 @@ static inline bool nd_iostat_start(struct bio *bio, unsigned long *start)
> > {
> > struct gendisk *disk = bio->bi_bdev->bd_disk;
> >
> > - if (!blk_queue_io_stat(disk->queue))
> > + if (!blk_queue_io_stat(disk->queue)) {
> > + *start = 0;
> > return false;
> > + }
> >
> > *start = jiffies;
> > generic_start_io_acct(bio_data_dir(bio),
>
> Well that's sad.
>
> The future of btt-remove-btt_rw_page.patch and friends is shrouded in
> mystery, but if we proceed that way then yes, I guess we'll need to
> work around such gcc glitches.
>
> But let's not leave apparently-unneeded code in place without telling
> people why it is in fact needed?
Maybe it's just cleaner to initialize 'start' in all the callers, so we don't
have a mysterious line and have to remember why it's there / comment it?
I'll throw a patch like that in my series if/when I repost.
next prev parent reply other threads:[~2017-08-01 22:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-01 11:48 [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning Arnd Bergmann
2017-08-01 11:48 ` Arnd Bergmann
2017-08-01 18:00 ` Ross Zwisler
2017-08-01 18:00 ` Ross Zwisler
2017-08-01 18:07 ` Dan Williams
2017-08-01 18:07 ` Dan Williams
2017-08-01 21:45 ` Andrew Morton
2017-08-01 21:45 ` Andrew Morton
2017-08-01 22:23 ` Ross Zwisler [this message]
2017-08-01 22:23 ` Ross Zwisler
2017-08-02 10:54 ` Arnd Bergmann
2017-08-02 10:54 ` Arnd Bergmann
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=20170801222347.GF20061@linux.intel.com \
--to=ross.zwisler@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
/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.