[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8558854.EA4z9rFkjX@wuerfel>
Date: Wed, 27 Jan 2016 16:21:54 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Måns Rullgård <mans@...sr.com>
Cc: "David S. Miller" <davem@...emloft.net>,
linux-arm-kernel@...ts.infradead.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 8/9] net: nb8800: avoid uninitialized variable warning
On Wednesday 27 January 2016 14:13:16 Måns Rullgård wrote:
> Arnd Bergmann <arnd@...db.de> writes:
>
> > The nb8800_poll() function initializes the 'next' variable in the
> > loop looking for new input data. We know this will be called at
> > least once because 'budget' is a guaranteed to be a positive number
> > when we enter the function, but the compiler doesn't know that
> > and warns when the variable is used later:
> >
> > drivers/net/ethernet/aurora/nb8800.c: In function 'nb8800_poll':
> > drivers/net/ethernet/aurora/nb8800.c:350:21: warning: 'next' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> Which gcc version is this? 4.9 doesn't warn here, presumably because
> it's clever enough to notice that the offending use of 'next' is under a
> condition that can only be true if the first one was. Of course fixing
> the code so older compilers don't warn is a good idea.
This was with gcc-5.2.1, but possibly in an unusual kernel configuration.
The only time I see it in my logs was with CONFIG_ARCH_IXP4XX=y, which
has its own mach/io.h and other headers that sometimes override generic
functions with a more elaborate version.
I have another patch for ixp4xx that simplifies its mach/io.h in order to
get rid of other false 'uninitialized use' warnings, but this one still
shows up with that other patch.
> > Changing the 'while() {}' loop to 'do {} while()' makes it obvious
> > to the compiler what is going on so it no longer warns.
> >
> > Signed-off-by: Arnd Bergmann <arnd@...db.de>
>
> Acked-by: Mans Rullgard <mans@...sr.com>
Thanks,
Arnd
Powered by blists - more mailing lists