public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 8250: Eliminate compile warning of 8250.c
@ 2008-11-25  3:55 Sheng Yang
  2008-11-25  3:58 ` Sheng Yang
  0 siblings, 1 reply; 9+ messages in thread
From: Sheng Yang @ 2008-11-25  3:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-serial, Sheng Yang, Alan Cox

The patch based on linux-2.6 upstream and elimiate this compile warning
info:

drivers/serial/8250.c: In function ‘serial8250_shutdown’:
drivers/serial/8250.c:1612: warning: ‘i’ may be used uninitialized in this
function

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
CC: Alan Cox <alan@redhat.com>
---
 drivers/serial/8250.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 303272a..c78eee6 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1609,7 +1609,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;
 
-- 
1.5.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH] 8250: Eliminate compile warning of 8250.c
  2008-11-25  3:55 [PATCH] 8250: Eliminate compile warning of 8250.c Sheng Yang
@ 2008-11-25  3:58 ` Sheng Yang
  2008-11-25 10:22   ` Alan Cox
  0 siblings, 1 reply; 9+ messages in thread
From: Sheng Yang @ 2008-11-25  3:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-serial, Sheng Yang

(Something wrong with encoding of the first mail...)

The patch based on linux-2.6 upstream and elimiate this compile warning
info:

drivers/serial/8250.c: In function 'serial8250_shutdown':
drivers/serial/8250.c:1612: warning: 'i' may be used uninitialized in this
function

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 drivers/serial/8250.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 303272a..c78eee6 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1609,7 +1609,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;
 
-- 
1.5.4.5


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

* Re: [PATCH] 8250: Eliminate compile warning of 8250.c
  2008-11-25  3:58 ` Sheng Yang
@ 2008-11-25 10:22   ` Alan Cox
  2008-11-25 10:31     ` Sheng Yang
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Cox @ 2008-11-25 10:22 UTC (permalink / raw)
  Cc: linux-kernel, linux-serial, Sheng Yang

On Tue, 25 Nov 2008 11:58:23 +0800
Sheng Yang <sheng@linux.intel.com> wrote:

> (Something wrong with encoding of the first mail...)
> 
> The patch based on linux-2.6 upstream and elimiate this compile warning
> info:
> 
> drivers/serial/8250.c: In function 'serial8250_shutdown':
> drivers/serial/8250.c:1612: warning: 'i' may be used uninitialized in this
> function

NAK - again.

There is no real bug here and you risk hiding future ones. It also
doesn't produce a warning with a modern gcc.

Alan

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

* Re: [PATCH] 8250: Eliminate compile warning of 8250.c
  2008-11-25 10:22   ` Alan Cox
@ 2008-11-25 10:31     ` Sheng Yang
  2008-11-25 10:43       ` Alan Cox
  0 siblings, 1 reply; 9+ messages in thread
From: Sheng Yang @ 2008-11-25 10:31 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel, linux-serial

On Tuesday 25 November 2008 18:22:30 Alan Cox wrote:
> On Tue, 25 Nov 2008 11:58:23 +0800
>
> Sheng Yang <sheng@linux.intel.com> wrote:
> > (Something wrong with encoding of the first mail...)
> >
> > The patch based on linux-2.6 upstream and elimiate this compile warning
> > info:
> >
> > drivers/serial/8250.c: In function 'serial8250_shutdown':
> > drivers/serial/8250.c:1612: warning: 'i' may be used uninitialized in
> > this function
>
> NAK - again.
>
> There is no real bug here and you risk hiding future ones. It also
> doesn't produce a warning with a modern gcc.

Can't understand initializing got "risk hiding future ones". As I know, didn't 
initialize the variable got risk hiding future random problems. If you think 
i=NULL is not enough, how about this? I don't use this version just because I 
think BUG_ON(n==null) cover this. And I don't think leave it to compiler is 
more proper here.

--
From: Sheng Yang <sheng@linux.intel.com>
Date: Tue, 25 Nov 2008 18:25:26 +0800
Subject: [PATCH 1/1] 8250: Eliminate compile warning of 8250.c

The patch based on linux-2.6 upstream and elimiate this compile warning
info:

drivers/serial/8250.c: In function 'serial8250_shutdown':
drivers/serial/8250.c:1612: warning: 'i' may be used uninitialized in this
function

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 drivers/serial/8250.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 303272a..c3120be 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1609,7 +1609,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;
 
@@ -1624,6 +1624,7 @@ static void serial_unlink_irq_chain(struct 
uart_8250_port *up)
 	}
 
 	BUG_ON(n == NULL);
+	BUG_ON(i == NULL);
 	BUG_ON(i->head == NULL);
 
 	if (list_empty(i->head))
-- 
1.5.4.5





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

* Re: [PATCH] 8250: Eliminate compile warning of 8250.c
  2008-11-25 10:31     ` Sheng Yang
@ 2008-11-25 10:43       ` Alan Cox
  2008-11-25 10:51         ` Sheng Yang
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Cox @ 2008-11-25 10:43 UTC (permalink / raw)
  To: Sheng Yang; +Cc: linux-kernel, linux-serial

> Can't understand initializing got "risk hiding future ones". As I know, didn't 

Because if you set it to NULL and later delete a line which does the
intended assignment you will no longer get a warning.

> think BUG_ON(n==null) cover this. And I don't think leave it to compiler is 
> more proper here.

The BUG_ON covers it, the current gcc gets this right and works it out.

NAK again


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

* Re: [PATCH] 8250: Eliminate compile warning of 8250.c
  2008-11-25 10:43       ` Alan Cox
@ 2008-11-25 10:51         ` Sheng Yang
  2008-11-25 11:12           ` Olivier Galibert
  2008-11-25 11:13           ` Alan Cox
  0 siblings, 2 replies; 9+ messages in thread
From: Sheng Yang @ 2008-11-25 10:51 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel, linux-serial

On Tuesday 25 November 2008 18:43:34 Alan Cox wrote:
> > Can't understand initializing got "risk hiding future ones". As I know,
> > didn't
>
> Because if you set it to NULL and later delete a line which does the
> intended assignment you will no longer get a warning.
>
> > think BUG_ON(n==null) cover this. And I don't think leave it to compiler
> > is more proper here.
>
> The BUG_ON covers it, the current gcc gets this right and works it out.
>
> NAK again

The logic here is strange...

If you used old compiler, you would get a warning, and you thought that's 
ensured we won't delete a intended assignment by mistake.

If you used new compiler, you wouldn't get a warning, and you think this time 
the compiler get it right.

So, what result did you expect? A warning to notice that we didn't delete a 
intended assignment, or a "right" result? 

OK. if you worry about "delete a line which does the intended assignment", the 
updated version with BUG_ON(i == NULL) can help. 

-- 
regards
Yang, Sheng


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

* Re: [PATCH] 8250: Eliminate compile warning of 8250.c
  2008-11-25 10:51         ` Sheng Yang
@ 2008-11-25 11:12           ` Olivier Galibert
  2008-11-25 11:13           ` Alan Cox
  1 sibling, 0 replies; 9+ messages in thread
From: Olivier Galibert @ 2008-11-25 11:12 UTC (permalink / raw)
  To: Sheng Yang; +Cc: Alan Cox, linux-kernel, linux-serial

On Tue, Nov 25, 2008 at 06:51:44PM +0800, Sheng Yang wrote:
> The logic here is strange...
> 
> If you used old compiler, you would get a warning, and you thought that's 
> ensured we won't delete a intended assignment by mistake.
> 
> If you used new compiler, you wouldn't get a warning, and you think this time 
> the compiler get it right.

The new compiler gets it right.  If you delete the assignment with the
new compiler, *then* you get a warning.


> OK. if you worry about "delete a line which does the intended assignment", the 
> updated version with BUG_ON(i == NULL) can help. 

Compile-time error detection is better than runtime.

  OG.

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

* Re: [PATCH] 8250: Eliminate compile warning of 8250.c
  2008-11-25 10:51         ` Sheng Yang
  2008-11-25 11:12           ` Olivier Galibert
@ 2008-11-25 11:13           ` Alan Cox
  2008-11-25 11:32             ` Sheng Yang
  1 sibling, 1 reply; 9+ messages in thread
From: Alan Cox @ 2008-11-25 11:13 UTC (permalink / raw)
  To: Sheng Yang; +Cc: linux-kernel, linux-serial

> The logic here is strange...

Why

> If you used old compiler, you would get a warning, and you thought that's 
> ensured we won't delete a intended assignment by mistake.

No.. if you hid the warning by hacking around the compiler mistake with
extra bogus assignments you would hide a future mistake.
> 
> If you used new compiler, you wouldn't get a warning, and you think this time 
> the compiler get it right.

The compiler does now get it right - I checked.

Alan

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

* Re: [PATCH] 8250: Eliminate compile warning of 8250.c
  2008-11-25 11:13           ` Alan Cox
@ 2008-11-25 11:32             ` Sheng Yang
  0 siblings, 0 replies; 9+ messages in thread
From: Sheng Yang @ 2008-11-25 11:32 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel, linux-serial

On Tuesday 25 November 2008 19:13:42 Alan Cox wrote:
> > The logic here is strange...
>
> Why
>
> > If you used old compiler, you would get a warning, and you thought that's
> > ensured we won't delete a intended assignment by mistake.
>
> No.. if you hid the warning by hacking around the compiler mistake with
> extra bogus assignments you would hide a future mistake.

OK, I got it now. 

Comparing the result of deleting a meaningful line, this modification result in 
no more warning.  And you also think one additional BUG_ON just for fixing 
compiler's mistake, so it's unacceptable. 

So leave the patch as it was. Seems many people need to upgrade compiler to 
avoid this thing. :)

-- 
regards
Yang, Sheng

>
> > If you used new compiler, you wouldn't get a warning, and you think this
> > time the compiler get it right.
>
> The compiler does now get it right - I checked.
>
> Alan


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

end of thread, other threads:[~2008-11-25 11:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-25  3:55 [PATCH] 8250: Eliminate compile warning of 8250.c Sheng Yang
2008-11-25  3:58 ` Sheng Yang
2008-11-25 10:22   ` Alan Cox
2008-11-25 10:31     ` Sheng Yang
2008-11-25 10:43       ` Alan Cox
2008-11-25 10:51         ` Sheng Yang
2008-11-25 11:12           ` Olivier Galibert
2008-11-25 11:13           ` Alan Cox
2008-11-25 11:32             ` Sheng Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox