Re: [PATCH] usb: fix uninitialized variables in keyspan_pda

From: Alan Cox
Date: Fri Jun 27 2008 - 05:16:32 EST


On Fri, 27 Jun 2008 10:58:54 +0300
Benny Halevy <bhalevy@xxxxxxxxxxx> wrote:

> The compiler (gcc 4.3.0) warns that status might be used uninitialized
> in keyspan_pda_tiocmget and keyspan_pda_tiocmset.
>
> It is technically correct and therefore this patch initializes
> status to 0 in both cases.
>
> Note that keyspan_pda_get_modem_info sets *value only when
> usb_control_msg returns rc > 0, otherwise it must
> return an error rc < 0, and it must never return rc == 0, hence
> a WARN_ON(rc == 0) was added in case usb_control_msg ever return 0.

That seems like overkill - and by forcing status to 0 you will hide
future gcc error catches. Far better to change the two callers to test
for > 0 not >= 0 surely ?

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