Skip to contentSkip to conversation

drivers/tty/serial: deal with 8250_core.c uninitialized warning for good

PATCH In review Paul Gortmaker 3 participants 4 messages Feb 19, 2014 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/tty/serial: deal with 8250_core.c uninitialized warning for good

Every couple of months, someone sends a patch to fix:

drivers/tty/serial/8250/8250_core.c: In function 'serial_unlink_irq_chain':
drivers/tty/serial/8250/8250_core.c:1712:2: warning: 'i' may be used uninitialized in this function [-Wuninitialized]

and they in turn get a NACK for their efforts, and are told that their compiler is broken. This has been going on since at least the year 2008: https://lkml.org/lkml/2008/11/24/433

Lets add a comment, so that subsequent patches don't get as far as the maintainers or the mailing lists.

drivers/tty/serial/8250/8250_core.c +4 -0
index 69932b7556cf..747073b8c38a 100644
@@ -1694,6 +1694,10 @@ static int serial_link_irq_chain(struct uart_8250_port *up)
 
 static void serial_unlink_irq_chain(struct uart_8250_port *up)
 {
+	/*
+	 * yes, some broken gcc emit "warning: 'i' may be used uninitialized"
+	 * but no, we are not going to take a patch that assigns NULL below.
+	 */
 	struct irq_info *i;
 	struct hlist_node *n;
 	struct hlist_head *h;
Signature · 1 line
1.8.5.2
#1 lore raw
Quoted 11 lines · Paul Gortmaker

Every couple of months, someone sends a patch to fix:

drivers/tty/serial/8250/8250_core.c: In function 'serial_unlink_irq_chain':
drivers/tty/serial/8250/8250_core.c:1712:2: warning: 'i' may be used uninitialized in this function [-Wuninitialized]

and they in turn get a NACK for their efforts, and are told that their compiler is broken. This has been going on since at least the year 2008: https://lkml.org/lkml/2008/11/24/433

Lets add a comment, so that subsequent patches don't get as far as the maintainers or the mailing lists.

Hi, wouldn't hlist_for_each_entry do a better job to silent both the compiler and the reporters with the added value of cleanup?

Quoted 8 lines
drivers/tty/serial/8250/8250_core.c +0 -0
index 69932b7556cf..747073b8c38a 100644

drivers/tty/serial/8250/8250_core.c static int serial_link_irq_chain(struct uart_8250_port *up) · line 1703

Quoted 10 lines
drivers/tty/serial/8250/8250_core.c +4 -0
@@ -1694,6 +1694,10 @@ static int serial_link_irq_chain(struct uart_8250_port *up)
 
 static void serial_unlink_irq_chain(struct uart_8250_port *up)
 {
+	/*
+	 * yes, some broken gcc emit "warning: 'i' may be used uninitialized"
+	 * but no, we are not going to take a patch that assigns NULL below.
+	 */
 	struct irq_info *i;
 	struct hlist_node *n;
 	struct hlist_head *h;

thanks,

Signature · 2 lines
js
suse labs
Acked-by on v1 1/1
#2 lore raw
In reply to Paul Gortmaker
Quoted 11 lines · Paul Gortmaker

Every couple of months, someone sends a patch to fix:

drivers/tty/serial/8250/8250_core.c: In function 'serial_unlink_irq_chain':
drivers/tty/serial/8250/8250_core.c:1712:2: warning: 'i' may be used uninitialized in this function [-Wuninitialized]

and they in turn get a NACK for their efforts, and are told that their compiler is broken. This has been going on since at least the year 2008: https://lkml.org/lkml/2008/11/24/433

Lets add a comment, so that subsequent patches don't get as far as the maintainers or the mailing lists.

Are people still using gcc variants that get this wrong ?

Fine by me.

#3 lore raw
Quoted 6 lines · Alan Cox
Quoted 5 lines · Paul Gortmaker

Every couple of months, someone sends a patch to fix:

drivers/tty/serial/8250/8250_core.c: In function 'serial_unlink_irq_chain':
drivers/tty/serial/8250/8250_core.c:1712:2: warning: 'i' may be used uninitialized in this function [-Wuninitialized]

Quoted 8 lines
Quoted 6 lines

and they in turn get a NACK for their efforts, and are told that their compiler is broken. This has been going on since at least the year 2008: https://lkml.org/lkml/2008/11/24/433

Lets add a comment, so that subsequent patches don't get as far as the maintainers or the mailing lists.

Are people still using gcc variants that get this wrong ?

It seems that gcc 4.6.3 gets it wrong, and it isn't _that_ old.

Paul.
--

$ mips-linux-gcc -v
Using built-in specs.
COLLECT_GCC=mips-linux-gcc
COLLECT_LTO_WRAPPER=/home/paul/tc/gcc-4.6.3-nolibc/mips-linux/bin/../libexec/gcc/mips-linux/4.6.3/lto-wrapper
Target: mips-linux
Configured with: /home/tony/buildall/src/gcc/configure --target=mips-linux --host=x86_64-linux-gnu --build=x86_64-linux-gnu --enable-targets=all --prefix=/opt/cross/gcc-4.6.3-nolibc/mips-linux/ --enable-languages=c --with-newlib --without-headers --enable-sjlj-exceptions --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-decimal-float --enable-checking=release --with-mpfr=/home/tony/buildall/src/sys-x86_64 --with-gmp=/home/tony/buildall/src/sys-x86_64 --disable-bootstrap --disable-libquadmath
Thread model: single
gcc version 4.6.3 (GCC) 
$ make allmodconfig > /dev/null
$ make drivers/tty/serial/8250/8250_core.o > /dev/null
drivers/tty/serial/8250/8250_core.c: In function 'serial_unlink_irq_chain':
drivers/tty/serial/8250/8250_core.c:1712:2: warning: 'i' may be used uninitialized in this function [-Wuninitialized]
$ 
Quoted 6 lines

Fine by me.