* [PATCH] tty/serial: Fix uninitialized variable warning
@ 2013-03-04 1:35 Grant Likely
2013-03-04 2:36 ` Peter Hurley
2013-03-15 20:30 ` Greg Kroah-Hartman
0 siblings, 2 replies; 5+ messages in thread
From: Grant Likely @ 2013-03-04 1:35 UTC (permalink / raw)
To: linux-serial, linux-kernel; +Cc: Grant Likely, Greg Kroah-Hartman
drivers/tty/serial/8250/8250.c: In function 'serial_unlink_irq_chain':
drivers/tty/serial/8250/8250.c:1676:19: warning: 'i' may be used uninitialized in this function
There isn't an actual bug here since the function tests the condition
that would cause i to be uninitialized before dereferencing i. However,
at least some versions of GCC complain as shown above. (in my case,
powerpc gcc 2.5.2). Initializing i to NULL makes it clear to GCC and the
casual code reviewer that i will not be dereferenced to a random
address.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Greg, some may argue that this is a tool problem, not a kernel problem,
but it is useful to me. If anyone objects I'm not going to spend any
time championing for this patch.
g.
drivers/tty/serial/8250/8250.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
index 0efc815..cbbedcf 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -1673,7 +1673,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.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] tty/serial: Fix uninitialized variable warning
2013-03-04 1:35 [PATCH] tty/serial: Fix uninitialized variable warning Grant Likely
@ 2013-03-04 2:36 ` Peter Hurley
2013-03-04 9:41 ` Jiri Slaby
2013-03-15 20:30 ` Greg Kroah-Hartman
1 sibling, 1 reply; 5+ messages in thread
From: Peter Hurley @ 2013-03-04 2:36 UTC (permalink / raw)
To: Grant Likely; +Cc: linux-serial, linux-kernel, Greg Kroah-Hartman
On Mon, 2013-03-04 at 09:35 +0800, Grant Likely wrote:
> drivers/tty/serial/8250/8250.c: In function 'serial_unlink_irq_chain':
> drivers/tty/serial/8250/8250.c:1676:19: warning: 'i' may be used uninitialized in this function
>
> There isn't an actual bug here since the function tests the condition
> that would cause i to be uninitialized before dereferencing i. However,
> at least some versions of GCC complain as shown above. (in my case,
> powerpc gcc 2.5.2). Initializing i to NULL makes it clear to GCC and the
> casual code reviewer that i will not be dereferenced to a random
> address.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> Greg, some may argue that this is a tool problem, not a kernel problem,
> but it is useful to me. If anyone objects I'm not going to spend any
> time championing for this patch.
>
> g.
>
> drivers/tty/serial/8250/8250.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
> index 0efc815..cbbedcf 100644
> --- a/drivers/tty/serial/8250/8250.c
> +++ b/drivers/tty/serial/8250/8250.c
> @@ -1673,7 +1673,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 irq_info *uninitialized_var(i);
For gcc, the uninitialized_var() #define is in
include/linux/compiler-gcc.h
Regards,
Peter Hurley
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tty/serial: Fix uninitialized variable warning
2013-03-04 2:36 ` Peter Hurley
@ 2013-03-04 9:41 ` Jiri Slaby
0 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2013-03-04 9:41 UTC (permalink / raw)
To: Peter Hurley, Grant Likely; +Cc: linux-serial, linux-kernel, Greg Kroah-Hartman
On 03/04/2013 03:36 AM, Peter Hurley wrote:
> On Mon, 2013-03-04 at 09:35 +0800, Grant Likely wrote:
>> drivers/tty/serial/8250/8250.c: In function 'serial_unlink_irq_chain':
>> drivers/tty/serial/8250/8250.c:1676:19: warning: 'i' may be used uninitialized in this function
>>
>> There isn't an actual bug here since the function tests the condition
>> that would cause i to be uninitialized before dereferencing i. However,
>> at least some versions of GCC complain as shown above. (in my case,
>> powerpc gcc 2.5.2). Initializing i to NULL makes it clear to GCC and the
>> casual code reviewer that i will not be dereferenced to a random
>> address.
>>
>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> ---
>> Greg, some may argue that this is a tool problem, not a kernel problem,
>> but it is useful to me. If anyone objects I'm not going to spend any
>> time championing for this patch.
>>
>> g.
>>
>> drivers/tty/serial/8250/8250.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
>> index 0efc815..cbbedcf 100644
>> --- a/drivers/tty/serial/8250/8250.c
>> +++ b/drivers/tty/serial/8250/8250.c
>> @@ -1673,7 +1673,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 irq_info *uninitialized_var(i);
>
> For gcc, the uninitialized_var() #define is in
> include/linux/compiler-gcc.h
As far as I remember, we decided not to use that macro any more after a
bug stemming out of its use.
And Grant uses a very old toolchain as we can see in the commit log. I'm
not sure whether it's worth to hide a potential bug in the future by
this patch.
thanks,
--
js
suse labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tty/serial: Fix uninitialized variable warning
2013-03-04 1:35 [PATCH] tty/serial: Fix uninitialized variable warning Grant Likely
2013-03-04 2:36 ` Peter Hurley
@ 2013-03-15 20:30 ` Greg Kroah-Hartman
2013-03-15 21:24 ` Grant Likely
1 sibling, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2013-03-15 20:30 UTC (permalink / raw)
To: Grant Likely; +Cc: linux-serial, linux-kernel
On Mon, Mar 04, 2013 at 09:35:07AM +0800, Grant Likely wrote:
> drivers/tty/serial/8250/8250.c: In function 'serial_unlink_irq_chain':
> drivers/tty/serial/8250/8250.c:1676:19: warning: 'i' may be used uninitialized in this function
>
> There isn't an actual bug here since the function tests the condition
> that would cause i to be uninitialized before dereferencing i. However,
> at least some versions of GCC complain as shown above. (in my case,
> powerpc gcc 2.5.2). Initializing i to NULL makes it clear to GCC and the
> casual code reviewer that i will not be dereferenced to a random
> address.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> Greg, some may argue that this is a tool problem, not a kernel problem,
> but it is useful to me. If anyone objects I'm not going to spend any
> time championing for this patch.
Upgrade your tools to ones that work properly :)
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tty/serial: Fix uninitialized variable warning
2013-03-15 20:30 ` Greg Kroah-Hartman
@ 2013-03-15 21:24 ` Grant Likely
0 siblings, 0 replies; 5+ messages in thread
From: Grant Likely @ 2013-03-15 21:24 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-serial, Linux Kernel Mailing List
On Fri, Mar 15, 2013 at 8:30 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Mon, Mar 04, 2013 at 09:35:07AM +0800, Grant Likely wrote:
>> drivers/tty/serial/8250/8250.c: In function 'serial_unlink_irq_chain':
>> drivers/tty/serial/8250/8250.c:1676:19: warning: 'i' may be used uninitialized in this function
>>
>> There isn't an actual bug here since the function tests the condition
>> that would cause i to be uninitialized before dereferencing i. However,
>> at least some versions of GCC complain as shown above. (in my case,
>> powerpc gcc 2.5.2). Initializing i to NULL makes it clear to GCC and the
>> casual code reviewer that i will not be dereferenced to a random
>> address.
>>
>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> ---
>> Greg, some may argue that this is a tool problem, not a kernel problem,
>> but it is useful to me. If anyone objects I'm not going to spend any
>> time championing for this patch.
>
> Upgrade your tools to ones that work properly :)
FWIW, it's still a toolchain that a lot of people use for embedded
powerpc development.
g.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-15 21:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-04 1:35 [PATCH] tty/serial: Fix uninitialized variable warning Grant Likely
2013-03-04 2:36 ` Peter Hurley
2013-03-04 9:41 ` Jiri Slaby
2013-03-15 20:30 ` Greg Kroah-Hartman
2013-03-15 21:24 ` Grant Likely
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.