[PATCH] serial/8250: fix uninitialized warnings - Kernel

This is a discussion on [PATCH] serial/8250: fix uninitialized warnings - Kernel ; fix following warnings. drivers/serial/8250.c: In function ‘serial8250_shutdown’: drivers/serial/8250.c:1612: warnings: ‘i’ may be used uninitialized in this function Signed-off-by: KOSAKI Motohiro CC: linux-serial@vger.kernel.org --- drivers/serial/8250.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: b/drivers/serial/8250.c ================================================== ================= --- a/drivers/serial/8250.c ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: [PATCH] serial/8250: fix uninitialized warnings

  1. [PATCH] serial/8250: fix uninitialized warnings


    fix following warnings.

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


    Signed-off-by: KOSAKI Motohiro
    CC: linux-serial@vger.kernel.org
    ---
    drivers/serial/8250.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    Index: b/drivers/serial/8250.c
    ================================================== =================
    --- a/drivers/serial/8250.c 2008-11-05 01:10:11.000000000 +0900
    +++ b/drivers/serial/8250.c 2008-11-05 01:38:39.000000000 +0900
    @@ -1609,7 +1609,7 @@ static int serial_link_irq_chain(struct

    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;



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

  2. Re: [PATCH] serial/8250: fix uninitialized warnings

    On Wed, 5 Nov 2008 02:26:00 +0900 (JST)
    KOSAKI Motohiro wrote:

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


    NAK

    This is an incorrect compiler warning. It's also one that current gcc
    does not emit warnings for.

    Alan
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. Re: [PATCH] serial/8250: fix uninitialized warnings

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

    >
    > NAK
    >
    > This is an incorrect compiler warning. It's also one that current gcc
    > does not emit warnings for.


    I see.
    Thanks!



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

  4. Re: [PATCH] serial/8250: fix uninitialized warnings

    On Tue, 4 Nov 2008 17:41:42 +0000
    Alan Cox wrote:

    > On Wed, 5 Nov 2008 02:26:00 +0900 (JST)
    > KOSAKI Motohiro wrote:
    >
    > >
    > > fix following warnings.
    > >
    > > drivers/serial/8250.c: In function ___serial8250_shutdown___:
    > > drivers/serial/8250.c:1612: warnings: ___i___ may be used uninitialized in this function

    >
    > NAK
    >
    > This is an incorrect compiler warning. It's also one that current gcc
    > does not emit warnings for.
    >


    That's a regression in current gcc, surely?

    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);


    #define hlist_for_each(pos, head) \
    for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
    pos = pos->next)

    hlist_for_each() can execute that loop zero times, in which case
    serial_unlink_irq_chain will dereference an uninitialised variable.

    Presumably the list shouldn't be empty at this stage, but this
    is not particularly robust behaviour if that should happen..
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. Re: [PATCH] serial/8250: fix uninitialized warnings

    > hlist_for_each() can execute that loop zero times, in which case
    > serial_unlink_irq_chain will dereference an uninitialised variable.
    >
    > Presumably the list shouldn't be empty at this stage, but this
    > is not particularly robust behaviour if that should happen..


    And the only cases that can trip are the more important BUG_ON() checks.
    You could remove the BUG_ON() calls and make it less robust but that
    seems slightly well silly to me ?

    Alan
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. Re: [PATCH] serial/8250: fix uninitialized warnings

    > That's a regression in current gcc, surely?

    Oh and as a PS: Gcc is I believe right because if the loop is run zero
    times then pos = NULL (ie n == NULL so the first BUG_ON fires)


    Alan
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  7. Re: [PATCH] serial/8250: fix uninitialized warnings

    On Mon, 10 Nov 2008 23:48:43 +0000
    Alan Cox wrote:

    > > That's a regression in current gcc, surely?

    >
    > Oh and as a PS: Gcc is I believe right because if the loop is run zero
    > times then pos = NULL (ie n == NULL so the first BUG_ON fires)


    Whoa. That would be clever of it.


    On about half the architectures, BUG is not considered to be no-return.
    Dunno if that's a gcc shortcoming or if the architectures just haven't
    implemented it properly yet. This causes those architectures to
    generate quite a few warnings in generic code which don't appear on
    x86 (this would be one such case if your above theory is correct).

    This is fairly irritating of those architectures, as I keep on going
    in asking "what's up" and deciding "oh, that again".
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  8. Re: [PATCH] serial/8250: fix uninitialized warnings

    From: Andrew Morton
    Date: Mon, 10 Nov 2008 15:58:08 -0800

    > On about half the architectures, BUG is not considered to be no-return.


    Right, it ought to be, whether implicitly (__builtin_trap() is something
    GCC considers no-return) or explicitly (if the arch uses inline
    asm or the generic bug.h code)
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread