All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: "Måns Rullgård" <mans@mansr.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 8/9] net: nb8800: avoid uninitialized variable warning
Date: Wed, 27 Jan 2016 16:21:54 +0100	[thread overview]
Message-ID: <8558854.EA4z9rFkjX@wuerfel> (raw)
In-Reply-To: <yw1xsi1jjekj.fsf@unicorn.mansr.com>

On Wednesday 27 January 2016 14:13:16 Måns Rullgård wrote:
> Arnd Bergmann <arnd@arndb.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@arndb.de>
> 
> Acked-by: Mans Rullgard <mans@mansr.com>

Thanks,

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 8/9] net: nb8800: avoid uninitialized variable warning
Date: Wed, 27 Jan 2016 16:21:54 +0100	[thread overview]
Message-ID: <8558854.EA4z9rFkjX@wuerfel> (raw)
In-Reply-To: <yw1xsi1jjekj.fsf@unicorn.mansr.com>

On Wednesday 27 January 2016 14:13:16 M?ns Rullg?rd wrote:
> Arnd Bergmann <arnd@arndb.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@arndb.de>
> 
> Acked-by: Mans Rullgard <mans@mansr.com>

Thanks,

	Arnd

  reply	other threads:[~2016-01-27 15:22 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-27 14:04 [PATCH 0/9] network driver fixes Arnd Bergmann
2016-01-27 14:04 ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 1/9] net: davinci_cpdma: use dma_addr_t for DMA address Arnd Bergmann
2016-01-27 14:04   ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 2/9] net: hp100: remove unnecessary #ifdefs Arnd Bergmann
2016-01-27 14:04   ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 3/9] net: bgmac: clarify CONFIG_BCMA dependency Arnd Bergmann
2016-01-27 14:04   ` Arnd Bergmann
2016-01-27 16:11   ` Paul Gortmaker
2016-01-27 16:11     ` Paul Gortmaker
2016-01-27 16:11     ` Paul Gortmaker
2016-01-28  8:49     ` Arnd Bergmann
2016-01-28  8:49       ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 4/9] net: moxart: use correct accessors for DMA memory Arnd Bergmann
2016-01-27 14:04   ` Arnd Bergmann
2016-01-28 12:36   ` David Laight
2016-01-28 12:36     ` David Laight
2016-01-28 16:53     ` Arnd Bergmann
2016-01-28 16:53       ` Arnd Bergmann
2016-01-28 16:58       ` Arnd Bergmann
2016-01-28 16:58         ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 5/9] net: fddi/defxx: avoid warning about uninitialized variable use Arnd Bergmann
2016-01-27 14:04   ` Arnd Bergmann
2016-01-27 15:15   ` Maciej W. Rozycki
2016-01-27 15:15     ` Maciej W. Rozycki
2016-01-27 14:04 ` [PATCH 6/9] net: vxge: avoid unused function warnings Arnd Bergmann
2016-01-27 14:04   ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 7/9] net: macb: avoid uninitialized variables Arnd Bergmann
2016-01-27 14:04   ` Arnd Bergmann
2016-01-27 15:51   ` Nicolas Ferre
2016-01-27 15:51     ` Nicolas Ferre
2016-01-27 16:04     ` Nicolas Ferre
2016-01-27 16:04       ` Nicolas Ferre
2016-01-28 16:32       ` Arnd Bergmann
2016-01-28 16:32         ` Arnd Bergmann
2016-01-28 13:27   ` Sergei Shtylyov
2016-01-28 13:27     ` Sergei Shtylyov
2016-01-27 14:04 ` [PATCH 8/9] net: nb8800: avoid uninitialized variable warning Arnd Bergmann
2016-01-27 14:04   ` Arnd Bergmann
2016-01-27 14:13   ` Måns Rullgård
2016-01-27 14:13     ` Måns Rullgård
2016-01-27 15:21     ` Arnd Bergmann [this message]
2016-01-27 15:21       ` Arnd Bergmann
2016-01-27 14:04 ` [PATCH 9/9] net: tg3: " Arnd Bergmann
2016-01-27 14:04   ` Arnd Bergmann
2016-01-29  0:14 ` [PATCH 0/9] network driver fixes David Miller
2016-01-29  0:14   ` David Miller
2016-01-29 12:56   ` Arnd Bergmann
2016-01-29 12:56     ` Arnd Bergmann

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=8558854.EA4z9rFkjX@wuerfel \
    --to=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mans@mansr.com \
    --cc=netdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.