Skip to contentSkip to conversation

serial: 8250: fix uninitialized compiler warning

PATCH NAK Davidlohr Bueso 3 participants 4 messages Nov 9, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: 8250: fix uninitialized compiler warning

From: Davidlohr Bueso <[email protected]>

This addresses:

CC [M] drivers/serial/8250.o
drivers/serial/8250.c: In function ‘serial8250_shutdown’:
drivers/serial/8250.c:1696: warning: ‘i’ may be used uninitialized in this function drivers/serial/8250.c:1696: note: ‘i’ was declared here

---
 drivers/serial/8250.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/serial/8250.c +1 -1
index 4d8e14b..f734eee 100644
@@ -1693,7 +1693,7 @@ static int serial_link_irq_chain(struct uart_8250_port *up)
 
 static void serial_unlink_irq_chain(struct uart_8250_port *up)
 {
-	struct irq_info *i;
+	struct irq_info *i = NULL;
 	struct hlist_node *n;
 	struct hlist_head *h;
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 8 lines · On Tue, 09 Nov 2010 13:55:23 -0300 Davidlohr Bueso wrote:

From: Davidlohr Bueso <[email protected]>

This addresses:

CC [M] drivers/serial/8250.o
drivers/serial/8250.c: In function ‘serial8250_shutdown’:
drivers/serial/8250.c:1696: warning: ‘i’ may be used uninitialized in this function drivers/serial/8250.c:1696: note: ‘i’ was declared here

so in your analysis of this compiler warning, was the warning correct & justified, or was it false? I.e., is the init to NULL needed?

If it was false, could we just quieten the warning by using:

	struct irq_info *unitialized_var(i);

plus #include <linux/compiler.h> ?

Quoted 11 lines
---
 drivers/serial/8250.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/serial/8250.c +0 -0
index 4d8e14b..f734eee 100644

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

Quoted 8 lines
drivers/serial/8250.c +1 -1
@@ -1693,7 +1693,7 @@ static int serial_link_irq_chain(struct uart_8250_port *up)
 
 static void serial_unlink_irq_chain(struct uart_8250_port *up)
 {
-	struct irq_info *i;
+	struct irq_info *i = NULL;
 	struct hlist_node *n;
 	struct hlist_head *h;
 

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#2 lore raw
In reply to Davidlohr Bueso
Quoted 8 lines · On Tue, 09 Nov 2010 13:55:23 -0300 Davidlohr Bueso <[email protected]> wrote:

From: Davidlohr Bueso <[email protected]>

This addresses:

CC [M] drivers/serial/8250.o
drivers/serial/8250.c: In function ‘serial8250_shutdown’:
drivers/serial/8250.c:1696: warning: ‘i’ may be used uninitialized in this function drivers/serial/8250.c:1696: note: ‘i’ was declared here

NAK - pleass see the four or five previous discussions on this one.

The current compilers all seem to get it right anyway.

Alan

#3 lore raw
Quoted 5 lines · Alan Cox
Quoted 2 lines · On Tue, 09 Nov 2010 13:55:23 -0300 Davidlohr Bueso <[email protected]> wrote:

From: Davidlohr Bueso <[email protected]>

Quoted 9 lines
Quoted 6 lines

This addresses:

CC [M] drivers/serial/8250.o
drivers/serial/8250.c: In function ‘serial8250_shutdown’:
drivers/serial/8250.c:1696: warning: ‘i’ may be used uninitialized in this function drivers/serial/8250.c:1696: note: ‘i’ was declared here

NAK - pleass see the four or five previous discussions on this one.

Yes I should have googled this one before sending.

Quoted 1 line

The current compilers all seem to get it right anyway.

This is with gcc 4.4.5 (ubuntu 10.10 - latest), released on October 1st, 2010 (quite current).

Thanks,
Davidlohr