Skip to contentSkip to conversation

Compile warning because of an uninitialized variable

PATCH In review Stephane Ouellette 2 participants 2 messages May 19, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Compile warning because of an uninitialized variable

Folks,

gcc generates a warning because of an uninitialized variable in arch/i386/kernel/cpu/transmeta.c.
The variable "cpu_freq" is initialized by a call to cpuid(). The following patch fixes the warning.

Regards,

Stephane.

arch/i386/kernel/cpu/transmeta.c +1 -0
@@ -18,6 +18,7 @@
 	/* Print CMS and CPU revision */
 	max = cpuid_eax(0x80860000);
 	cpu_rev = 0;
+	cpu_freq = 0;
 	if ( max >= 0x80860001 ) {
 		cpuid(0x80860001, &dummy, &cpu_rev, &cpu_freq, &cpu_flags); 
 		if (cpu_rev != 0x02000000) {
#1 lore raw
Quoted 6 lines · Stephane Ouellette

Folks,

gcc generates a warning because of an uninitialized variable in arch/i386/kernel/cpu/transmeta.c.
The variable "cpu_freq" is initialized by a call to cpuid(). The following patch fixes the warning.

This is a gcc bug. The variable is passed by reference to a function where the assignment is made.
The second time it's used, if that > 80860002 condition is satisfied, we *must* have satisfied the previous check where we made the assignment, as 'max' hasn't changed between the two checks.

Dave

Signature · 1 line
http://www.codemonkey.org.uk