Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1701531
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning |
| Date | 2017-08-01 23:50 +0200 |
| Message-ID | <u9Nd7-UI-17@gated-at.bofh.it> (permalink) |
| References | <u9E0a-3xA-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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?
--- a/drivers/nvdimm/nd.h~nvdimm-avoid-bogus-wmaybe-uninitialized-warning-fix
+++ a/drivers/nvdimm/nd.h
@@ -393,7 +393,7 @@ static inline bool nd_iostat_start(struc
struct gendisk *disk = bio->bi_bdev->bd_disk;
if (!blk_queue_io_stat(disk->queue)) {
- *start = 0;
+ *start = 0; /* Suppress bogus warning */
return false;
}
_
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2017-08-01 14:00 +0200
Re: [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning Ross Zwisler <ross.zwisler@linux.intel.com> - 2017-08-01 20:10 +0200
Re: [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning Dan Williams <dan.j.williams@intel.com> - 2017-08-01 20:10 +0200
Re: [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning Andrew Morton <akpm@linux-foundation.org> - 2017-08-01 23:50 +0200
Re: [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning Ross Zwisler <ross.zwisler@linux.intel.com> - 2017-08-02 00:30 +0200
Re: [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning Arnd Bergmann <arnd@arndb.de> - 2017-08-02 13:00 +0200
csiph-web