* [PATCH] arch/i386/kernel/cpu/transmeta.c, kernel 2.6.17.8
@ 2006-08-09 17:49 Forrest Voight
2006-08-09 20:18 ` Michael Tokarev
2006-08-09 21:30 ` Oleg Verych
0 siblings, 2 replies; 3+ messages in thread
From: Forrest Voight @ 2006-08-09 17:49 UTC (permalink / raw)
To: linux-kernel
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
--- linux-2.6.17.8/arch/i386/kernel/cpu/transmeta.c 2006-08-07
00:18:54.000000000 -0400
+++ linux/arch/i386/kernel/cpu/transmeta.c 2006-08-09
13:32:05.000000000 -0400
@@ -9,7 +9,7 @@
{
unsigned int cap_mask, uk, max, dummy;
unsigned int cms_rev1, cms_rev2;
- unsigned int cpu_rev, cpu_freq, cpu_flags, new_cpu_rev;
+ unsigned int cpu_rev, cpu_freq = 0, cpu_flags, new_cpu_rev;
char cpu_info[65];
get_model_name(c); /* Same as AMD/Cyrix */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arch/i386/kernel/cpu/transmeta.c, kernel 2.6.17.8
2006-08-09 17:49 [PATCH] arch/i386/kernel/cpu/transmeta.c, kernel 2.6.17.8 Forrest Voight
@ 2006-08-09 20:18 ` Michael Tokarev
2006-08-09 21:30 ` Oleg Verych
1 sibling, 0 replies; 3+ messages in thread
From: Michael Tokarev @ 2006-08-09 20:18 UTC (permalink / raw)
To: Forrest Voight; +Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arch/i386/kernel/cpu/transmeta.c, kernel 2.6.17.8
2006-08-09 17:49 [PATCH] arch/i386/kernel/cpu/transmeta.c, kernel 2.6.17.8 Forrest Voight
2006-08-09 20:18 ` Michael Tokarev
@ 2006-08-09 21:30 ` Oleg Verych
1 sibling, 0 replies; 3+ messages in thread
From: Oleg Verych @ 2006-08-09 21:30 UTC (permalink / raw)
To: linux-kernel
Forrest Voight:
> Corrects warning:
> 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
> - unsigned int cpu_rev, cpu_freq, cpu_flags, new_cpu_rev;
> + unsigned int cpu_rev, cpu_freq = 0, cpu_flags, new_cpu_rev;
If one doesn't want to add more init code, but variable indeed used
uninitialazed, in GCC 3.X struct may be used, GCC 4.X needs 'volatile'.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-08-09 23:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-09 17:49 [PATCH] arch/i386/kernel/cpu/transmeta.c, kernel 2.6.17.8 Forrest Voight
2006-08-09 20:18 ` Michael Tokarev
2006-08-09 21:30 ` Oleg Verych
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox