From: Michael Tokarev <mjt@tls.msk.ru>
To: Forrest Voight <voights@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arch/i386/kernel/cpu/transmeta.c, kernel 2.6.17.8
Date: Thu, 10 Aug 2006 00:18:34 +0400 [thread overview]
Message-ID: <44DA431A.1010902@tls.msk.ru> (raw)
In-Reply-To: <b572c9e10608091049q5223adddxb2fd854c31877670@mail.gmail.com>
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
next prev parent reply other threads:[~2006-08-09 20:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2006-08-09 21:30 ` Oleg Verych
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44DA431A.1010902@tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=voights@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox