Fix warning in powernow-k8.c
PATCH 1/1 Fix warning in powernow-k8.c
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
arch/i386/kernel/cpu/cpufreq/powernow-k8.c +2 -3
@@ -110,14 +110,13 @@ static int query_current_values_with_penu32 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 ;
Hi!
Quoted 4 lines
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
Quoted 23 lines
Signed-off-by Brian Gerst <[email protected]>arch/i386/kernel/cpu/cpufreq/powernow-k8.c +2
-3@@ -110,14 +110,13 @@ static int query_current_values_with_penu32 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 ;
Quoted 9 lines · Pavel Machek
Hi!
Quoted 4 lines
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
Quoted 4 lines
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.
Quoted 29 lines
Pavel
Quoted 23 lines
Signed-off-by Brian Gerst <[email protected]>arch/i386/kernel/cpu/cpufreq/powernow-k8.c +2
-3@@ -110,14 +110,13 @@ static int query_current_values_with_penu32 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 ;
Quoted 10 lines · Brian Gerst
Quoted 9 lines · Pavel Machek
Hi!
Quoted 4 lines
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
Quoted 8 lines
Quoted 4 lines
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