From patchwork Thu Apr 25 17:28:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 2489661 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id DCC103FD85 for ; Thu, 25 Apr 2013 18:42:18 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVQ5t-0005fE-Nm; Thu, 25 Apr 2013 17:36:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVQ0D-0007FR-PE; Thu, 25 Apr 2013 17:30:37 +0000 Received: from moutng.kundenserver.de ([212.227.126.171]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UVPyo-00072a-Ut for linux-arm-kernel@lists.infradead.org; Thu, 25 Apr 2013 17:29:23 +0000 Received: from wuerfel.lan (HSI-KBW-095-208-002-043.hsi5.kabel-badenwuerttemberg.de [95.208.2.43]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0Lcg0l-1UxHnx3Sop-00k7Z3; Thu, 25 Apr 2013 19:29:07 +0200 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 15/21] thermal: cooling: avoid uninitialied used gcc warning Date: Thu, 25 Apr 2013 19:28:58 +0200 Message-Id: <1366910944-3033663-16-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1366910944-3033663-1-git-send-email-arnd@arndb.de> References: <1366910944-3033663-1-git-send-email-arnd@arndb.de> X-Provags-ID: V02:K0:rKDFEauA4/R4HXGmWx8UQ7UyZHXUICuFD5AY4H5dNI9 2SRGqtLvYYhsB0be3wNVZj6CgHy/75REDoYmD7SoL5Fy6P30P5 vukWw86p4SMj2EsczaJ4w/6gm2mrTReaavLTgsSHmfRsIG75JA 9KjTodb69nqnq2qg3M1AwxCjRlJboM7hw3HOu3z1ruPNuGoKpB tr95EFiTfjldjNnHewV+qn2d0mMCRayrlG9hEezBObAMoR92vA NXht7OU8jBkbkNZOTmf0/7KBOEV7mi2iiQb6k5ixPpdFFWGWgN FhLrs9zSxj8r6U6MG6lhw21z0g+w/77OEIIaloU+Oqx4TWDIcS ysTWPBicZ0SNyLQ6b5bm1yY6iye/6UhkTmqiiAdpZ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130425_132911_970525_DDC6E2C0 X-CRM114-Status: GOOD ( 12.83 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.171 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Zhang Rui , Amit Daniel kachhap , linux-kernel@vger.kernel.org, Arnd Bergmann X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The newly rewritten get_property() function causes a bogus warning from gcc-3.8, which cannot figure out that "level" is always initialized at the point where it gets evaluated: drivers/thermal/cpu_cooling.c: In function 'get_property': drivers/thermal/cpu_cooling.c:189:37: warning: 'level' may be used uninitialized in this function [-Wmaybe-uninitialized] if (property == GET_FREQ && level == j) { ^ Slightly rearranging the code makes this more obvious and avoids the warning. Signed-off-by: Arnd Bergmann Cc: Zhang Rui Cc: Amit Daniel kachhap --- drivers/thermal/cpu_cooling.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 768b508..34878e6 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -165,10 +165,6 @@ static int get_property(unsigned int cpu, unsigned long input, return 0; } - if (property == GET_FREQ) - level = descend ? input : (max_level - input -1); - - for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { /* ignore invalid entry */ if (table[i].frequency == CPUFREQ_ENTRY_INVALID) @@ -186,10 +182,15 @@ static int get_property(unsigned int cpu, unsigned long input, *output = descend ? j : (max_level - j - 1); return 0; } - if (property == GET_FREQ && level == j) { - /* get frequency by level */ - *output = freq; - return 0; + + if (property == GET_FREQ) { + level = descend ? input : (max_level - input -1); + + if (level == j) { + /* get frequency by level */ + *output = freq; + return 0; + } } j++; }