lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 25 Apr 2013 19:28:58 +0200
From:	Arnd Bergmann <arnd@...db.de>
To:	linux-arm-kernel@...ts.infradead.org
Cc:	linux-kernel@...r.kernel.org, Arnd Bergmann <arnd@...db.de>,
	Zhang Rui <rui.zhang@...el.com>,
	Amit Daniel kachhap <amit.daniel@...sung.com>
Subject: [PATCH 15/21] thermal: cooling: avoid uninitialied used gcc warning

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 <arnd@...db.de>
Cc: Zhang Rui <rui.zhang@...el.com>
Cc: Amit Daniel kachhap <amit.daniel@...sung.com>
---
 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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ