drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
is a genuine bug. The function returns an uninitialized value of 'err'
back to the caller, which expects it to be 0 for success cases. Let's
fix this by explicitly initializing 'err' to zero.
Signed-off-by: Satyam Sharma <[email protected]>
---
drivers/net/3c59x.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- linux-2.6.23-rc4-mm1/drivers/net/3c59x.c~fix 2007-09-04 03:29:40.000000000 +0530
+++ linux-2.6.23-rc4-mm1/drivers/net/3c59x.c 2007-09-04 03:30:08.000000000 +0530
@@ -1492,7 +1492,8 @@ vortex_up(struct net_device *dev)
struct vortex_private *vp = netdev_priv(dev);
void __iomem *ioaddr = vp->ioaddr;
unsigned int config;
- int i, mii_reg1, mii_reg5, err;
+ int i, mii_reg1, mii_reg5;
+ int err = 0;
if (VORTEX_PCI(vp)) {
pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */
Remove duplicate entry for the same driver.
Signed-off-by: Satyam Sharma <[email protected]>
---
MAINTAINERS | 6 ------
1 file changed, 6 deletions(-)
--- linux-2.6.23-rc4-mm1/MAINTAINERS~fix 2007-09-04 03:49:16.000000000 +0530
+++ linux-2.6.23-rc4-mm1/MAINTAINERS 2007-09-04 03:49:28.000000000 +0530
@@ -104,12 +104,6 @@ M: [email protected]
L: [email protected]
S: Maintained
-3C59X NETWORK DRIVER
-P: Steffen Klassert
-M: [email protected]
-L: [email protected]
-S: Maintained
-
3CR990 NETWORK DRIVER
P: David Dillow
M: [email protected]
On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
>
> drivers/net/3c59x.c: In function 'vortex_up':
> drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
not notice the warning yet.
>
> is a genuine bug. The function returns an uninitialized value of 'err'
> back to the caller, which expects it to be 0 for success cases. Let's
> fix this by explicitly initializing 'err' to zero.
>
> Signed-off-by: Satyam Sharma <[email protected]>
Acked-by: Steffen Klassert <[email protected]>
On Tue, Sep 04, 2007 at 03:52:50AM +0530, Satyam Sharma wrote:
> Remove duplicate entry for the same driver.
This is -mm specific. Andrew did not remove the add-3c59x-maintainer
patch after pushing it to mainline. This can be fixed just by removing
the add-3c59x-maintainer patch from -mm.
Hi Steffen,
On Tue, 4 Sep 2007, Steffen Klassert wrote:
> On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
> >
> > drivers/net/3c59x.c: In function 'vortex_up':
> > drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
>
> This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
> from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
> not notice the warning yet.
Hmm, the .config I built with had PCI=y as well. Probably a compiler
version difference -- Jeff also mentioned yesterday that some newer
GCC versions fail to warn about uninitialized variables cases.
> > is a genuine bug. The function returns an uninitialized value of 'err'
> > back to the caller, which expects it to be 0 for success cases. Let's
> > fix this by explicitly initializing 'err' to zero.
> >
> > Signed-off-by: Satyam Sharma <[email protected]>
> Acked-by: Steffen Klassert <[email protected]>
Thanks,
Satyam
On Tue, Sep 04, 2007 at 02:09:47PM +0530, Satyam Sharma wrote:
> Hi Steffen,
>
>
> On Tue, 4 Sep 2007, Steffen Klassert wrote:
>
> > On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
> > >
> > > drivers/net/3c59x.c: In function 'vortex_up':
> > > drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
> >
> > This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
> > from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
> > not notice the warning yet.
>
> Hmm, the .config I built with had PCI=y as well. Probably a compiler
> version difference -- Jeff also mentioned yesterday that some newer
> GCC versions fail to warn about uninitialized variables cases.
>
Sorry, this is my bad. I have just checked: there is no warning with gcc
4.2 or 4.1, but 3.3 emits the warning.
>
> > > is a genuine bug. The function returns an uninitialized value of 'err'
> > > back to the caller, which expects it to be 0 for success cases. Let's
> > > fix this by explicitly initializing 'err' to zero.
> > >
> > > Signed-off-by: Satyam Sharma <[email protected]>
> > Acked-by: Steffen Klassert <[email protected]>
Acked-by: Mark Hindley <[email protected]>
On Tue, Sep 04, 2007 at 09:53:31AM +0100, Mark Hindley wrote:
> On Tue, Sep 04, 2007 at 02:09:47PM +0530, Satyam Sharma wrote:
> > Hi Steffen,
> >
> >
> > On Tue, 4 Sep 2007, Steffen Klassert wrote:
> >
> > > On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
> > > >
> > > > drivers/net/3c59x.c: In function 'vortex_up':
> > > > drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
> > >
> > > This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
> > > from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
> > > not notice the warning yet.
> >
> > Hmm, the .config I built with had PCI=y as well. Probably a compiler
> > version difference -- Jeff also mentioned yesterday that some newer
> > GCC versions fail to warn about uninitialized variables cases.
> >
>
> Sorry, this is my bad. I have just checked: there is no warning with gcc
> 4.2 or 4.1, but 3.3 emits the warning.
>
The only warning that I was able to trigger with gcc 4.2 is in the case of a .config
without PCI support. In this case I get
drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1672: warning: 'err' is used uninitialized in this function
^^
So we have to be more carefull with the newer gcc versions.
Steffen
On Tue, Sep 04, 2007 at 11:17:57AM +0200, Steffen Klassert wrote:
> The only warning that I was able to trigger with gcc 4.2 is in the case of a .config
> without PCI support. In this case I get
>
> drivers/net/3c59x.c: In function 'vortex_up':
> drivers/net/3c59x.c:1672: warning: 'err' is used uninitialized in this function
That should be fixed by Satyam's patch too.
Mark
On Tue, Sep 04, 2007 at 10:35:10AM +0100, Mark Hindley wrote:
> On Tue, Sep 04, 2007 at 11:17:57AM +0200, Steffen Klassert wrote:
>
> > The only warning that I was able to trigger with gcc 4.2 is in the case of a .config
> > without PCI support. In this case I get
> >
> > drivers/net/3c59x.c: In function 'vortex_up':
> > drivers/net/3c59x.c:1672: warning: 'err' is used uninitialized in this function
>
> That should be fixed by Satyam's patch too.
Yes, of course.
This was just to point out what's possible to trigger with a newer gcc and what's not.
Steffen
On Tue, 4 Sep 2007, Mark Hindley wrote:
> On Tue, Sep 04, 2007 at 02:09:47PM +0530, Satyam Sharma wrote:
> > Hi Steffen,
> >
> >
> > On Tue, 4 Sep 2007, Steffen Klassert wrote:
> >
> > > On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
> > > >
> > > > drivers/net/3c59x.c: In function 'vortex_up':
> > > > drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
> > >
> > > This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
> > > from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
> > > not notice the warning yet.
> >
> > Hmm, the .config I built with had PCI=y as well. Probably a compiler
> > version difference -- Jeff also mentioned yesterday that some newer
> > GCC versions fail to warn about uninitialized variables cases.
> >
>
> Sorry, this is my bad. I have just checked: there is no warning with gcc
> 4.2 or 4.1, but 3.3 emits the warning.
This is a GCC bug (regression, actually, as you've found out) -- no two
ways about it. Although different from the kind Jeff mentioned couple days
back -- that was about wising GCC up to false positives and /not/ emitting
warnings. But here a genuine problem was not complained about, so this is
more serious. Do you plan to open up a bug at gcc.gnu.org/bugzilla/ ?
Satyam
On Thu, Sep 06, 2007 at 03:25:55PM +0530, Satyam Sharma wrote:
> This is a GCC bug (regression, actually, as you've found out) -- no two
> ways about it. Although different from the kind Jeff mentioned couple days
> back -- that was about wising GCC up to false positives and /not/ emitting
> warnings. But here a genuine problem was not complained about, so this is
> more serious. Do you plan to open up a bug at gcc.gnu.org/bugzilla/ ?
>
Yes, I have just narrowed down a test case, which is remarkably simple!
int
main(int i)
{
int err;
if (i) {
err = 1;
}
return err;
}
Mark