All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: lpfc: avoid false-positive gcc-8 warning
@ 2017-08-23 15:01 Arnd Bergmann
  2017-08-23 16:20 ` James Smart
  2017-08-23 19:02 ` Arnd Bergmann
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-08-23 15:01 UTC (permalink / raw)
  To: James Smart, Dick Kennedy, James E.J. Bottomley, Martin K. Petersen
  Cc: Arnd Bergmann, Hannes Reinecke, linux-scsi, linux-kernel

This is an interesting regression with gcc-8, showing a harmless
warning for correct code:

In file included from include/linux/kernel.h:13:0,
                 ...
                 from drivers/scsi/lpfc/lpfc_debugfs.c:23:
include/linux/printk.h:301:2: error: 'eq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
  ^~~~~~
In file included from drivers/scsi/lpfc/lpfc_debugfs.c:58:0:
drivers/scsi/lpfc/lpfc_debugfs.h:451:31: note: 'eq' was declared here

I tried to come up with a reduced test case for gcc here
a few times, but every time ended up with code that is actually
wrong with older gcc versions missing the bug and gcc-8 finding
it. As this is the only false-positive -Wmaybe-uninitialized
warnign I got with gcc-8 randconfig builds, I'd suggest we
work around it.

Making the index variable 'unsigned' is enough to shut up
the warning, as gcc can then see that comparing eqidx to
phba->io_channel_irqs is fine here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/lpfc/lpfc_debugfs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.h b/drivers/scsi/lpfc/lpfc_debugfs.h
index 7b7d314af0e0..7b7f53a37fd8 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.h
+++ b/drivers/scsi/lpfc/lpfc_debugfs.h
@@ -450,7 +450,7 @@ lpfc_debug_dump_cq(struct lpfc_hba *phba, int qtype, int wqidx)
 {
 	struct lpfc_queue *wq, *cq, *eq;
 	char *qtypestr;
-	int eqidx;
+	unsigned int eqidx;
 
 	/* fcp/nvme wq and cq are 1:1, thus same indexes */
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: lpfc: avoid false-positive gcc-8 warning
  2017-08-23 15:01 [PATCH] scsi: lpfc: avoid false-positive gcc-8 warning Arnd Bergmann
@ 2017-08-23 16:20 ` James Smart
  2017-08-23 19:02 ` Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: James Smart @ 2017-08-23 16:20 UTC (permalink / raw)
  To: Arnd Bergmann, Dick Kennedy, James E.J. Bottomley, Martin K. Petersen
  Cc: Hannes Reinecke, linux-scsi, linux-kernel

On 8/23/2017 8:01 AM, Arnd Bergmann wrote:
> This is an interesting regression with gcc-8, showing a harmless
> warning for correct code:
>
> In file included from include/linux/kernel.h:13:0,
>                   ...
>                   from drivers/scsi/lpfc/lpfc_debugfs.c:23:
> include/linux/printk.h:301:2: error: 'eq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
>    ^~~~~~
> In file included from drivers/scsi/lpfc/lpfc_debugfs.c:58:0:
> drivers/scsi/lpfc/lpfc_debugfs.h:451:31: note: 'eq' was declared here
>
> I tried to come up with a reduced test case for gcc here
> a few times, but every time ended up with code that is actually
> wrong with older gcc versions missing the bug and gcc-8 finding
> it. As this is the only false-positive -Wmaybe-uninitialized
> warnign I got with gcc-8 randconfig builds, I'd suggest we
> work around it.
>
> Making the index variable 'unsigned' is enough to shut up
> the warning, as gcc can then see that comparing eqidx to
> phba->io_channel_irqs is fine here.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/scsi/lpfc/lpfc_debugfs.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
>
looks good. Thanks

Signed-off-by: James Smart <james.smart@broadcom.com>

-- james

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: lpfc: avoid false-positive gcc-8 warning
  2017-08-23 15:01 [PATCH] scsi: lpfc: avoid false-positive gcc-8 warning Arnd Bergmann
  2017-08-23 16:20 ` James Smart
@ 2017-08-23 19:02 ` Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-08-23 19:02 UTC (permalink / raw)
  To: James Smart, Dick Kennedy, James E.J. Bottomley, Martin K. Petersen
  Cc: Arnd Bergmann, Hannes Reinecke, linux-scsi, Linux Kernel Mailing List

On Wed, Aug 23, 2017 at 5:01 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> This is an interesting regression with gcc-8, showing a harmless
> warning for correct code:
>
> In file included from include/linux/kernel.h:13:0,
>                  ...
>                  from drivers/scsi/lpfc/lpfc_debugfs.c:23:
> include/linux/printk.h:301:2: error: 'eq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
>   ^~~~~~
> In file included from drivers/scsi/lpfc/lpfc_debugfs.c:58:0:
> drivers/scsi/lpfc/lpfc_debugfs.h:451:31: note: 'eq' was declared here
>
> I tried to come up with a reduced test case for gcc here
> a few times, but every time ended up with code that is actually
> wrong with older gcc versions missing the bug and gcc-8 finding
> it. As this is the only false-positive -Wmaybe-uninitialized
> warnign I got with gcc-8 randconfig builds, I'd suggest we
> work around it.
>
> Making the index variable 'unsigned' is enough to shut up
> the warning, as gcc can then see that comparing eqidx to
> phba->io_channel_irqs is fine here.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Sorry, I have to retract my patch. While it apparently solved the problem
for most randconfig builds, I have now run into another case that it did
not address, and I still get the warning for one caller:

In file included from /git/arm-soc/include/linux/kernel.h:13:0,
                 from /git/arm-soc/arch/x86/include/asm/percpu.h:44,
                 from /git/arm-soc/arch/x86/include/asm/current.h:5,
                 from /git/arm-soc/include/linux/sched.h:11,
                 from /git/arm-soc/include/linux/blkdev.h:4,
                 from /git/arm-soc/drivers/scsi/lpfc/lpfc_debugfs.c:23:
/git/arm-soc/drivers/scsi/lpfc/lpfc_debugfs.c: In function
'lpfc_debug_dump_all_queues':
/git/arm-soc/include/linux/printk.h:301:2: error: 'eq' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
  ^~~~~~
In file included from /git/arm-soc/drivers/scsi/lpfc/lpfc_debugfs.c:58:0:
/git/arm-soc/drivers/scsi/lpfc/lpfc_debugfs.h:451:31: note: 'eq' was
declared here
  struct lpfc_queue *wq, *cq, *eq;
                               ^~
In file included from /git/arm-soc/include/linux/kernel.h:13:0,
                 from /git/arm-soc/arch/x86/include/asm/percpu.h:44,
                 from /git/arm-soc/arch/x86/include/asm/current.h:5,
                 from /git/arm-soc/include/linux/sched.h:11,
                 from /git/arm-soc/include/linux/blkdev.h:4,
                 from /git/arm-soc/drivers/scsi/lpfc/lpfc_debugfs.c:23:
/git/arm-soc/include/linux/printk.h:301:2: error: 'eq' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
  ^~~~~~
In file included from /git/arm-soc/drivers/scsi/lpfc/lpfc_debugfs.c:58:0:
/git/arm-soc/drivers/scsi/lpfc/lpfc_debugfs.h:451:31: note: 'eq' was
declared here
  struct lpfc_queue *wq, *cq, *eq;
                               ^~
cc1: all warnings being treated as errors

     Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-23 19:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-23 15:01 [PATCH] scsi: lpfc: avoid false-positive gcc-8 warning Arnd Bergmann
2017-08-23 16:20 ` James Smart
2017-08-23 19:02 ` Arnd Bergmann

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.