Forrest Voight wrote:
> Corrects warning:
>
> CC arch/i386/kernel/cpu/centaur.o
> CC arch/i386/kernel/cpu/transmeta.o
> arch/i386/kernel/cpu/transmeta.c: In function 'init_transmeta':
> arch/i386/kernel/cpu/transmeta.c:12: warning: 'cpu_freq' may be used
> uninitialized in this function
> CC arch/i386/kernel/cpu/intel.o
>
This is a false alarm.
Here's the code (details omitted):
if ( max >= 0x80860001 ) {
cpuid(0x80860001, &dummy, &cpu_rev, &cpu_freq, &cpu_flags);
^^^^^^^^^
}
if ( max >= 0x80860002 ) {
printk(KERN_INFO "CPU: Processor %u MHz\n", cpu_freq);
}
Note the two conditions: if second is true, the first is
true too, so both branches are executed, so first cpu_freq
is initialized (by cpuid() call) and next it's used in printk.
The same thing will be done by the following code:
if ( max >= 0x80860001 ) {
cpuid(0x80860001, &dummy, &cpu_rev, &cpu_freq, &cpu_flags);
if ( max >= 0x80860002 ) {
printk(KERN_INFO "CPU: Processor %u MHz\n", cpu_freq);
}
}
and in this case gcc will not (hopefully) issue the warning.
BTW, cpu_rev gets initialized to 0 here as well - looks like
it's done also just to prevent warning message.
/mjt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]