xilinx_uartps.c: suppress "may be used uninitialised" warning
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 31 Jul 2019 06:05:57 +0000 (16:05 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Sep 2019 10:43:49 +0000 (12:43 +0200)
A powerpc allyesconfig build produces this warning:

In file included from include/linux/radix-tree.h:16,
                 from include/linux/idr.h:15,
                 from include/linux/kernfs.h:13,
                 from include/linux/sysfs.h:16,
                 from include/linux/kobject.h:20,
                 from include/linux/device.h:16,
                 from include/linux/platform_device.h:13,
                 from drivers/tty/serial/xilinx_uartps.c:16:
drivers/tty/serial/xilinx_uartps.c: In function 'cdns_uart_console_write':
include/linux/spinlock.h:288:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
   _raw_spin_unlock_irqrestore(lock, flags); \
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/tty/serial/xilinx_uartps.c:1197:16: note: 'flags' was declared here
  unsigned long flags;
                ^~~~~

It looks like gcc just can't track the relationship between "locked"
and "flags", and it is obvious that "flags" won't be used when "locked"
is zero, so the simplest thing is to initialise flags.

Cc: Jiri Slaby <jslaby@suse.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Link: https://lore.kernel.org/r/20190731160557.6a09c3e1@canb.auug.org.au
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/xilinx_uartps.c

index f145946f659b424ffa5e79ec0ac3086ed6ef19c1..da4563aaaf5c9db19d379d075bb0d95e785c5966 100644 (file)
@@ -1194,7 +1194,7 @@ static void cdns_uart_console_write(struct console *co, const char *s,
                                unsigned int count)
 {
        struct uart_port *port = console_port;
-       unsigned long flags;
+       unsigned long flags = 0;
        unsigned int imr, ctrl;
        int locked = 1;