Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932933Ab3DYRcU (ORCPT ); Thu, 25 Apr 2013 13:32:20 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:54544 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932737Ab3DYR32 (ORCPT ); Thu, 25 Apr 2013 13:29:28 -0400 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Zhang Rui , Amit Daniel kachhap 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2006 Lines: 62 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++; } -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/