virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] XEN: enlighten, use uninitialized_var(cx)
@ 2009-08-25 21:00 Jiri Slaby
  2009-08-25 22:29 ` Jeremy Fitzhardinge
  2009-08-26  6:09 ` Ingo Molnar
  0 siblings, 2 replies; 4+ messages in thread
From: Jiri Slaby @ 2009-08-25 21:00 UTC (permalink / raw)
  To: jeremy; +Cc: chrisw, virtualization, xen-devel, linux-kernel, 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.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Chris Wright <chrisw@sous-sol.org>
---
 arch/x86/xen/enlighten.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index e90540a..5ab75e2 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -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 */
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] XEN: enlighten, use uninitialized_var(cx)
  2009-08-25 21:00 [PATCH 1/1] XEN: enlighten, use uninitialized_var(cx) Jiri Slaby
@ 2009-08-25 22:29 ` Jeremy Fitzhardinge
  2009-08-26  6:09 ` Ingo Molnar
  1 sibling, 0 replies; 4+ messages in thread
From: Jeremy Fitzhardinge @ 2009-08-25 22:29 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: xen-devel, jeremy, the arch/x86 maintainers, linux-kernel, chrisw,
	virtualization, Ingo Molnar

On 08/25/09 14:00, Jiri Slaby wrote:
> 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.
>
> Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
> Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
> Cc: Chris Wright <chrisw@sous-sol.org>
>   
Acked-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>

> ---
>  arch/x86/xen/enlighten.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> index e90540a..5ab75e2 100644
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -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 */
>   

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] XEN: enlighten, use uninitialized_var(cx)
  2009-08-25 21:00 [PATCH 1/1] XEN: enlighten, use uninitialized_var(cx) Jiri Slaby
  2009-08-25 22:29 ` Jeremy Fitzhardinge
@ 2009-08-26  6:09 ` Ingo Molnar
  2009-08-26 17:27   ` H. Peter Anvin
  1 sibling, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2009-08-26  6:09 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: jeremy, chrisw, virtualization, xen-devel, linux-kernel


* Jiri Slaby <jirislaby@gmail.com> wrote:

> 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.
> 
> Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
> Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
> Cc: Chris Wright <chrisw@sous-sol.org>
> ---
>  arch/x86/xen/enlighten.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> index e90540a..5ab75e2 100644
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] XEN: enlighten, use uninitialized_var(cx)
  2009-08-26  6:09 ` Ingo Molnar
@ 2009-08-26 17:27   ` H. Peter Anvin
  0 siblings, 0 replies; 4+ messages in thread
From: H. Peter Anvin @ 2009-08-26 17:27 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: xen-devel, Jiri Slaby, linux-kernel, chrisw, virtualization,
	jeremy

On 08/25/2009 11:09 PM, Ingo Molnar wrote:
>>
>> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
>> index e90540a..5ab75e2 100644
>> --- a/arch/x86/xen/enlighten.c
>> +++ b/arch/x86/xen/enlighten.c
>> @@ -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.
> 

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-26 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-25 21:00 [PATCH 1/1] XEN: enlighten, use uninitialized_var(cx) Jiri Slaby
2009-08-25 22:29 ` Jeremy Fitzhardinge
2009-08-26  6:09 ` Ingo Molnar
2009-08-26 17:27   ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).