From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933615AbcA0PWc (ORCPT ); Wed, 27 Jan 2016 10:22:32 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:65204 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932740AbcA0PWa convert rfc822-to-8bit (ORCPT ); Wed, 27 Jan 2016 10:22:30 -0500 From: Arnd Bergmann To: =?ISO-8859-1?Q?M=E5ns_Rullg=E5rd?= Cc: "David S. Miller" , 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 Message-ID: <8558854.EA4z9rFkjX@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: <1453903507-3427225-1-git-send-email-arnd@arndb.de> <1453903507-3427225-9-git-send-email-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset="iso-8859-1" X-Provags-ID: V03:K0:sg0mjzAqTiYuKRrd8NxmlV+gDDw1quJVcS5Mq6cIKSVDoz3AcYy CjwSv4cJRWiF6JeG8chErvW1ih1SHyK6L0TvDLr+cP54DVOyPtg4AYrDsKY+ZFmMko77SY6 1g/n2Z5mxED1MeTOca3W+QTjwJCvo/ZSMZ29V4J2+0afYuH7Z3RSu2UyPgphxwdCFDM3Zdi eh5ZspJ4MZbafvB5XFuuA== X-UI-Out-Filterresults: notjunk:1;V01:K0:1YS+uWvK+Lc=:r3Z6l8kq+AaWAni0V2FJ+2 nqokyfoHM7MQg6prgjr44TdofuRmORraa7Kf5QsGZ2PSI7k8AC5b66M/mDVji4eT5QWB82A7k SL7/pc0O2vpkjNPub8fzDSsiDrKJYHHh9T2PhKf8XtUYExRkcWkW2x7k6ghCbNh3nyv09vaO/ Qd7f+psLQjM+twuCiSfnIOIOSpDOz8pq82Pg4pCOOnrdQZ67K5Wv7OziIoY1j8bwP5q3JZOHg pQhX/hJIWIqegLNVAVyRFBgu60N71IQOg8fbKaXfmhD1GTWVLV4bBO2ufLkj3m2xLvbBUd9sK PFSNw0lcY8rtMBByeQej4XKhT+pyOXLZuI5LLLKL6JWye/YFcM7xppzDOMb6X/fP/td2a6Eln 2VYLXsr58ST+zE/Tu/KRJccI3gIE0wu37ZTMUJaj7UsWBg4iiYriWEdCDzkNs3Ct2QjPnDWmc GCcmWW1FWp5BmBOZvio11YyJIv6awVRT7pu9j8pgNA1T+JQEYvmI5wu6Up5kMHa/N0vhFC17+ tV93xHd1NnraKs8peful4ZNDSacamAaWTqvFCQgm1QaU7zJ1nhbJMfHYGkdw4HwrJszhNxddb nAmtFQGDbKSJ0NKfO5xsYbfUQeDgkycdRoBrBsHI9DRS8e8/tmi99c90kMV3Ys6xcEK05IAs9 GggHVKLuYC9LWFnzga+KoQkZWGp/1PBr1I3wrBEjH9rgTQI5uthzL9y8avbfTzv0sCXp3PBAJ PlpBF7/EP3ntOZ8p Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 27 January 2016 14:13:16 Måns Rullgård wrote: > Arnd Bergmann 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 > > Acked-by: Mans Rullgard Thanks, Arnd