lkml.org 
[lkml]   [2009]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [Compile Warning] 2.6.30-rc8 build
Date
 > To my reading of the function, I think gcc has a point:
>
> drivers/serial/8250.c: In function 'serial8250_shutdown':
> drivers/serial/8250.c:1685: warning: 'i' may be used uninitialized in this function
>
> It does read as if the code might try to initialize
> the 'lock' field of a null pointer.

The code in question is:

static void serial_unlink_irq_chain(struct uart_8250_port *up)
{
struct irq_info *i;
struct hlist_node *n;
struct hlist_head *h;

mutex_lock(&hash_mutex);

h = &irq_lists[up->port.irq % NR_IRQ_HASH];

hlist_for_each(n, h) {
i = hlist_entry(n, struct irq_info, node);
if (i->irq == up->port.irq)
break;
}

BUG_ON(n == NULL);
BUG_ON(i->head == NULL);

if (list_empty(i->head))
free_irq(up->port.irq, i);

and if the hlist_for_each() doesn't find a matching irq_info to put in
i, then the BUG_ON(n == NULL) will kill the system. So there's no bug
although it is understandable that gcc can't see that.

(Not sure why you talk about "the 'lock' field of a null pointer" -- I
assume your gcc warns about the function serial8250_shutdown() because
it is inlining a function only called from a single location)

- R.


\
 
 \ /
  Last update: 2009-06-05 19:25    [W:0.414 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site