Skip to contentSkip to conversation

x86: fix apic.h unused but set warnings v2

PATCH In review Andi Kleen 3 participants 6 messages Nov 8, 2010 – Nov 9, 2010 x86

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 x86: fix apic.h unused but set warnings v2

From: Andi Kleen <[email protected]>

Fix

linux-2.6/arch/x86/include/asm/apic.h: In function 'native_apic_msr_read':
linux-2.6/arch/x86/include/asm/apic.h:144:11: warning: variable 'high' set but not used [-Wunused-but-set-variable] linux-2.6/arch/x86/include/asm/apic.h: In function 'x2apic_enabled':
linux-2.6/arch/x86/include/asm/apic.h:184:11: warning: variable 'msr2' set but not used [-Wunused-but-set-variable]

which happen with a gcc 4.6 build

Since this is in a frequently included header these warnings are printed very frequently and make a gcc 4.6 build very noisy.

v2: Add cast and change types based on review feedback.

---
 arch/x86/include/asm/apic.h |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
arch/x86/include/asm/apic.h +5 -5
index 286de34..e5472de 100644
@@ -141,13 +141,13 @@ static inline void native_apic_msr_write(u32 reg, u32 v)
 
 static inline u32 native_apic_msr_read(u32 reg)
 {
-	u32 low, high;
+	u32 low;
 
 	if (reg == APIC_DFR)
 		return -1;
 
-	rdmsr(APIC_BASE_MSR + (reg >> 4), low, high);
-	return low;
+	rdmsrl(APIC_BASE_MSR + (reg >> 4), low);
+	return (u32)low;
 }
 
 static inline void native_x2apic_wait_icr_idle(void)
@@ -181,12 +181,12 @@ extern void enable_x2apic(void);
 extern void x2apic_icr_write(u32 low, u32 id);
 static inline int x2apic_enabled(void)
 {
-	int msr, msr2;
+	u32 msr;
 
 	if (!cpu_has_x2apic)
 		return 0;
 
-	rdmsr(MSR_IA32_APICBASE, msr, msr2);
+	rdmsrl(MSR_IA32_APICBASE, msr);
 	if (msr & X2APIC_ENABLE)
 		return 1;
 	return 0;
Signature · 1 line
1.7.1
#1 lore raw

arch/x86/include/asm/apic.h static inline void native_apic_msr_write(u32 reg, u32 v) · line 150

Quoted 12 lines · Andi Kleen

static inline u32 native_apic_msr_read(u32 reg)
{

arch/x86/include/asm/apic.h +3 -3
-	u32 low, high;
+	u32 low;
 
 	if (reg == APIC_DFR)
 		return -1;
 
-	rdmsr(APIC_BASE_MSR + (reg >> 4), low, high);
-	return low;
+	rdmsrl(APIC_BASE_MSR + (reg >> 4), low);
+	return (u32)low;

What's the point of casting u32 to u32 ?

Thanks,

tglx

author
#2 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 8 lines · Andi Kleen

static inline u32 native_apic_msr_read(u32 reg)
{

arch/x86/include/asm/apic.h +1 -1
-	u32 low, high;
+	u32 low;
 
 	if (reg == APIC_DFR)
 		return -1;
Quoted 6 lines

arch/x86/include/asm/apic.h static inline void native_apic_msr_write(u32 reg, u32 v) · line 150

Quoted 4 lines
arch/x86/include/asm/apic.h +2 -2
-	rdmsr(APIC_BASE_MSR + (reg >> 4), low, high);
-	return low;
+	rdmsrl(APIC_BASE_MSR + (reg >> 4), low);
+	return (u32)low;

What's the point of casting u32 to u32 ?

One of the earlier reviewers thought adding an explicit cast would make the truncation in the code clearer. I didn't full agree either, but still did the change.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#3 lore raw
Quoted 18 lines · Andi Kleen
Quoted 9 lines · Thomas Gleixner
Quoted 8 lines · Andi Kleen

static inline u32 native_apic_msr_read(u32 reg)
{

arch/x86/include/asm/apic.h +1 -1
-	u32 low, high;
+	u32 low;
 
 	if (reg == APIC_DFR)
 		return -1;
Quoted 6 lines

arch/x86/include/asm/apic.h static inline void native_apic_msr_write(u32 reg, u32 v) · line 150

Quoted 4 lines
arch/x86/include/asm/apic.h +2 -2
-	rdmsr(APIC_BASE_MSR + (reg >> 4), low, high);
-	return low;
+	rdmsrl(APIC_BASE_MSR + (reg >> 4), low);
+	return (u32)low;

What's the point of casting u32 to u32 ?

Quoted 5 lines

One of the earlier reviewers thought adding an explicit cast would make the truncation in the code clearer. I didn't full agree either, but still did the change.

-Andi

Well, Andi I proposed to define variable as u64 and convert it back to u32 at procedure exit point. That would be clean, and I still think so ;) Though I'm fine with either way (I just thought about ones who will be reading this code in future, and since most the rdmsrl callers already use u64 and unsigned long, this would be consistent as well).

Cyrill

author
#4 lore raw
Quoted 5 lines

Well, Andi I proposed to define variable as u64 and convert it back to u32 at procedure exit point. That would be clean, and I still think so ;) Though I'm fine with either way (I just thought about ones who will be reading this code in future, and since most the rdmsrl callers already use u64 and unsigned long, this would be consistent as well).

I didn't use u64 because that would use more code on i386

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#5 lore raw
Quoted 9 lines · Andi Kleen
Quoted 5 lines

Well, Andi I proposed to define variable as u64 and convert it back to u32 at procedure exit point. That would be clean, and I still think so ;) Though I'm fine with either way (I just thought about ones who will be reading this code in future, and since most the rdmsrl callers already use u64 and unsigned long, this would be consistent as well).

I didn't use u64 because that would use more code on i386

-Andi

Fair enough. Thanks Andi.

Cyrill