From patchwork Wed Jan 27 14:04:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101068 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2603325lbb; Wed, 27 Jan 2016 06:08:28 -0800 (PST) X-Received: by 10.66.102.106 with SMTP id fn10mr43289188pab.60.1453903708714; Wed, 27 Jan 2016 06:08:28 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fk1si9764814pad.35.2016.01.27.06.08.28; Wed, 27 Jan 2016 06:08:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933065AbcA0OI0 (ORCPT + 30 others); Wed, 27 Jan 2016 09:08:26 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:51346 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754362AbcA0OIW (ORCPT ); Wed, 27 Jan 2016 09:08:22 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue002) with ESMTPA (Nemesis) id 0LzCmv-1a2YHH0W5x-014XKE; Wed, 27 Jan 2016 15:07:50 +0100 From: Arnd Bergmann To: "David S. Miller" Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , netdev@vger.kernel.org, =?utf-8?b?TcOlbnMgUnVsbGfDpXJk?= , linux-kernel@vger.kernel.org Subject: [PATCH 8/9] net: nb8800: avoid uninitialized variable warning Date: Wed, 27 Jan 2016 15:04:58 +0100 Message-Id: <1453903507-3427225-9-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1453903507-3427225-1-git-send-email-arnd@arndb.de> References: <1453903507-3427225-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:Zi9m2E7sNbWRHP6o/ojA12AMkfI3oSRNXPbkFH6rQw8krjCqj32 3UtMO+zeoIeGKc+ZkC7k/HYHN6YyoGdlLpMEY7MG4qWzLIMw+kkinh+ZstHGY2HIAglGyuN 49u9rVS0HQGlM0dndbMRjw5GPBlh3e7LzjvITgCvshGVd5kcRxd9o+7C0t2AJBEVMhCpZE5 N6Dp/XQBdA1aoDm13dlZA== X-UI-Out-Filterresults: notjunk:1; V01:K0:D3Nnmw2zh6g=:XgjAu/qfCMMZdSq7jo2Un4 t3CRr36Dpcf6JfiN2Bbl+qvVJPQhgVyuV5DHMrgDNrPDNlNLrz8RxeCgZOfe64lohOTEmGbRk BUzcDFuxiGIf7/bvXmcTDoqgXKoXMyljxPIlZJuoq3YM2yoT9UUZ/GH+Ojz1qdgBgDQHqPCG8 9BrU9CiTVJwMQMkFeQRSLr8X6+SQNZBApQ+GUUbSq2WsL4BSe8bIGIkqrnd+e23Yv+NFRVsbd wNWRdflQUe/MDci1JIuVzhe2CGk2nqDv+EaztwD2/nOASoaRf9If7Nz8wI80Qj9kpN2beiFl1 6UrKxXY1eWOYmdKC78BtWdTVjJKo9gVUAV+oRJA4nY3u8JIZ7aAXs6oXa1OlGPKgDQkNJGioc W7YgDDRgdqSMS3LJIh/lOJ3yJyZVvucohdoULHHkhZ1TfhGwC6b85ultulJEUL1L6AxbOz4P4 +sLa6S4GQ6Cdt5D7BWchYmwhV8IG4hquT9M7API+wtFIY2MaZ+mh5QUdws0aS8LDYEFqFWHce unP4ETvcRzpTNI0JmSVzA0jjyl7DFtPOwPNBf1p1IyZBzxH05teMstlI3xcc1h6UbyKaIRh6G RsTksn9ms4PMcWuv3c+tyRxFO4qGcdEl7YcDRGZn2zFKnE8us3PIGpTYvBATp8PkA/mZmD6M9 /Bd3nY6oC/WeISuoSvf98R2WPIkBoz18bfaPrwG5lpco+jvSmjRQrlpQsLv55M3pX9q0= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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] 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 --- drivers/net/ethernet/aurora/nb8800.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.0 Acked-by: Mans Rullgard diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c index ecc4a334c507..f71ab2647a3b 100644 --- a/drivers/net/ethernet/aurora/nb8800.c +++ b/drivers/net/ethernet/aurora/nb8800.c @@ -302,7 +302,7 @@ static int nb8800_poll(struct napi_struct *napi, int budget) nb8800_tx_done(dev); again: - while (work < budget) { + do { struct nb8800_rx_buf *rxb; unsigned int len; @@ -330,7 +330,7 @@ again: rxd->report = 0; last = next; work++; - } + } while (work < budget); if (work) { priv->rx_descs[last].desc.config |= DESC_EOC;