Skip to contentSkip to conversation

XEN: enlighten, use uninitialized_var(cx)

PATCH In review Jiri Slaby 4 participants 4 messages Aug 25, 2009 – Aug 26, 2009

Subsystems (3)
lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 XEN: enlighten, use uninitialized_var(cx)

To avoid a wrong compiler warning, use unitialized_var(cx) in xen_init_cpuid_mask.

cx needn't be initialized for cpuid when ax is 1.

Cc Jeremy Fitzhardinge <[email protected]>
Cc Chris Wright <[email protected]>
---
 arch/x86/xen/enlighten.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/xen/enlighten.c +1 -1
index e90540a..5ab75e2 100644
@@ -202,7 +202,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 
 static __init void xen_init_cpuid_mask(void)
 {
-	unsigned int ax, bx, cx, dx;
+	unsigned int ax, bx, uninitialized_var(cx), dx;
 
 	cpuid_leaf1_edx_mask =
 		~((1 << X86_FEATURE_MCE)  |  /* disable MCE */
Signature · 1 line
1.6.3.3
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jiri Slaby

To avoid a wrong compiler warning, use unitialized_var(cx) in xen_init_cpuid_mask.

cx needn't be initialized for cpuid when ax is 1.

Cc Jeremy Fitzhardinge <[email protected]>
Cc Chris Wright <[email protected]>
Quoted 18 lines
---
 arch/x86/xen/enlighten.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/xen/enlighten.c +1 -1
index e90540a..5ab75e2 100644
@@ -202,7 +202,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 
 static __init void xen_init_cpuid_mask(void)
 {
-	unsigned int ax, bx, cx, dx;
+	unsigned int ax, bx, uninitialized_var(cx), dx;
 
 	cpuid_leaf1_edx_mask =
 		~((1 << X86_FEATURE_MCE)  |  /* disable MCE */
#2 lore raw
In reply to Jiri Slaby
Quoted 17 lines · Jiri Slaby

To avoid a wrong compiler warning, use unitialized_var(cx) in xen_init_cpuid_mask.

cx needn't be initialized for cpuid when ax is 1.

Cc Jeremy Fitzhardinge <[email protected]>
Cc Chris Wright <[email protected]>
---
 arch/x86/xen/enlighten.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/xen/enlighten.c +0 -0
index e90540a..5ab75e2 100644

arch/x86/xen/enlighten.c static void xen_cpuid(unsigned int *ax, unsigned int *bx, · line 205

Quoted 5 lines
arch/x86/xen/enlighten.c +1 -1
@@ -202,7 +202,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 
 static __init void xen_init_cpuid_mask(void)
 {
-	unsigned int ax, bx, cx, dx;
+	unsigned int ax, bx, uninitialized_var(cx), dx;

Please dont use uninitialized_var(), it's an unreliable facility: if this variable ever grows a real used-without-initialization bug in the future, the compiler warning is turned off permanently. It's rare but might happen. We are better off with initializing it to zero.

Ingo

#3 lore raw
Quoted 7 lines · Ingo Molnar
Quoted 7 lines
arch/x86/xen/enlighten.c +0 -0
index e90540a..5ab75e2 100644
@@ -202,7 +202,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 
Quoted 11 lines

arch/x86/xen/enlighten.c static void xen_cpuid(unsigned int *ax, unsigned int *bx, · line 205

Quoted 4 lines
arch/x86/xen/enlighten.c +1 -1
 static __init void xen_init_cpuid_mask(void)
 {
-	unsigned int ax, bx, cx, dx;
+	unsigned int ax, bx, uninitialized_var(cx), dx;

Please dont use uninitialized_var(), it's an unreliable facility: if this variable ever grows a real used-without-initialization bug in the future, the compiler warning is turned off permanently. It's rare but might happen. We are better off with initializing it to zero.

I hadn't seen this thread, but I pushed a patch to x86/urgent to do exactly that while I was committing the Xen crash patch last night.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.