public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Benny Halevy <bhalevy@panasas.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: fix uninitialized variables in keyspan_pda
Date: Fri, 27 Jun 2008 13:25:03 -0700	[thread overview]
Message-ID: <20080627202503.GC15414@kroah.com> (raw)
In-Reply-To: <4864B158.6080301@panasas.com>

On Fri, Jun 27, 2008 at 12:22:32PM +0300, Benny Halevy wrote:
> On Jun. 27, 2008, 11:58 +0300, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> > On Fri, 27 Jun 2008 10:58:54 +0300
> > Benny Halevy <bhalevy@panasas.com> 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 ?
> 
> Well, since usb_control_msg is not supposed to ever return 0
> I'm really not sure what to do if it does. I'll gladly defer that
> decision to Greg...

It's not supposed to return 0 unless you pass in 0 as the length to be
transferred (not likely, but possible.)  So I'm referring to the case in
the keyspan driver where the return value can not be zero, sorry for any
confusion.

> The following patch makes gcc happy as you said and if it's
> correct I, too, like it much better.

I like it better too, make it more obvious.

thanks,

greg k-h

      reply	other threads:[~2008-06-27 20:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-26 14:52 keyspan_pda.c use of keyspan_pda_get_modem_info Benny Halevy
2008-06-26 15:23 ` Alan Cox
2008-06-27  4:17   ` Greg KH
2008-06-27  7:18     ` Benny Halevy
2008-06-27  7:58       ` [PATCH] usb: fix uninitialized variables in keyspan_pda Benny Halevy
2008-06-27  8:58         ` Alan Cox
2008-06-27  9:22           ` Benny Halevy
2008-06-27 20:25             ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080627202503.GC15414@kroah.com \
    --to=greg@kroah.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=bhalevy@panasas.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox