* [PATCH] Fix warning in powernow-k8.c
@ 2005-06-02 16:58 Brian Gerst
2005-06-03 16:11 ` Pavel Machek
0 siblings, 1 reply; 4+ messages in thread
From: Brian Gerst @ 2005-06-02 16:58 UTC (permalink / raw)
To: davej; +Cc: lkml
[-- Attachment #1: Type: text/plain, Size: 214 bytes --]
Fix this warning:
powernow-k8.c: In function ‘query_current_values_with_pending_wait’:
powernow-k8.c:110: warning: ‘hi’ may be used uninitialized in this function
Signed-off-by: Brian Gerst <bgerst@didntduck.org>
[-- Attachment #2: powernow-k8 --]
[-- Type: text/plain, Size: 651 bytes --]
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -110,14 +110,13 @@ static int query_current_values_with_pen
u32 lo, hi;
u32 i = 0;
- lo = MSR_S_LO_CHANGE_PENDING;
- while (lo & MSR_S_LO_CHANGE_PENDING) {
+ do {
if (i++ > 0x1000000) {
printk(KERN_ERR PFX "detected change pending stuck\n");
return 1;
}
rdmsr(MSR_FIDVID_STATUS, lo, hi);
- }
+ } while (lo & MSR_S_LO_CHANGE_PENDING);
data->currvid = hi & MSR_S_HI_CURRENT_VID;
data->currfid = lo & MSR_S_LO_CURRENT_FID;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix warning in powernow-k8.c
2005-06-02 16:58 [PATCH] Fix warning in powernow-k8.c Brian Gerst
@ 2005-06-03 16:11 ` Pavel Machek
2005-06-03 18:31 ` Brian Gerst
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2005-06-03 16:11 UTC (permalink / raw)
To: Brian Gerst; +Cc: davej, lkml
Hi!
> Fix this warning:
> powernow-k8.c: In function ?query_current_values_with_pending_wait?:
> powernow-k8.c:110: warning: ?hi? may be used uninitialized in this
> function
Are you sure?
Original code is clearly buggy; I do not think you need that ugly do
{} while loop.
Pavel
>
> Signed-off-by: Brian Gerst <bgerst@didntduck.org>
> diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
> --- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
> +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
> @@ -110,14 +110,13 @@ static int query_current_values_with_pen
> u32 lo, hi;
> u32 i = 0;
>
> - lo = MSR_S_LO_CHANGE_PENDING;
> - while (lo & MSR_S_LO_CHANGE_PENDING) {
> + do {
> if (i++ > 0x1000000) {
> printk(KERN_ERR PFX "detected change pending stuck\n");
> return 1;
> }
> rdmsr(MSR_FIDVID_STATUS, lo, hi);
> - }
> + } while (lo & MSR_S_LO_CHANGE_PENDING);
>
> data->currvid = hi & MSR_S_HI_CURRENT_VID;
> data->currfid = lo & MSR_S_LO_CURRENT_FID;
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix warning in powernow-k8.c
2005-06-03 16:11 ` Pavel Machek
@ 2005-06-03 18:31 ` Brian Gerst
2005-06-03 18:56 ` Pavel Machek
0 siblings, 1 reply; 4+ messages in thread
From: Brian Gerst @ 2005-06-03 18:31 UTC (permalink / raw)
To: Pavel Machek; +Cc: davej, lkml
Pavel Machek wrote:
> Hi!
>
>
>>Fix this warning:
>>powernow-k8.c: In function ?query_current_values_with_pending_wait?:
>>powernow-k8.c:110: warning: ?hi? may be used uninitialized in this
>>function
>
>
> Are you sure?
>
> Original code is clearly buggy; I do not think you need that ugly do
> {} while loop.
I'm not sure why you think the loop is ugly. It makes it more obvious
(to us humans and the compiler) that the loop is executed at least one time.
>
> Pavel
>
>>Signed-off-by: Brian Gerst <bgerst@didntduck.org>
>
>
>>diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
>>--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
>>+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
>>@@ -110,14 +110,13 @@ static int query_current_values_with_pen
>> u32 lo, hi;
>> u32 i = 0;
>>
>>- lo = MSR_S_LO_CHANGE_PENDING;
>>- while (lo & MSR_S_LO_CHANGE_PENDING) {
>>+ do {
>> if (i++ > 0x1000000) {
>> printk(KERN_ERR PFX "detected change pending stuck\n");
>> return 1;
>> }
>> rdmsr(MSR_FIDVID_STATUS, lo, hi);
>>- }
>>+ } while (lo & MSR_S_LO_CHANGE_PENDING);
>>
>> data->currvid = hi & MSR_S_HI_CURRENT_VID;
>> data->currfid = lo & MSR_S_LO_CURRENT_FID;
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix warning in powernow-k8.c
2005-06-03 18:31 ` Brian Gerst
@ 2005-06-03 18:56 ` Pavel Machek
0 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2005-06-03 18:56 UTC (permalink / raw)
To: Brian Gerst; +Cc: davej, lkml
On Pá 03-06-05 14:31:48, Brian Gerst wrote:
> Pavel Machek wrote:
> >Hi!
> >
> >
> >>Fix this warning:
> >>powernow-k8.c: In function ?query_current_values_with_pending_wait?:
> >>powernow-k8.c:110: warning: ?hi? may be used uninitialized in this
> >>function
> >
> >
> >Are you sure?
> >
> >Original code is clearly buggy; I do not think you need that ugly do
> >{} while loop.
>
> I'm not sure why you think the loop is ugly. It makes it more obvious
> (to us humans and the compiler) that the loop is executed at least
> one time.
Oops, sorry, I misread the patch.
Pavel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-06-03 18:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-02 16:58 [PATCH] Fix warning in powernow-k8.c Brian Gerst
2005-06-03 16:11 ` Pavel Machek
2005-06-03 18:31 ` Brian Gerst
2005-06-03 18:56 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox