Re: [PATCH] kvm: Fix build warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 31 May 2011 09:38:24 +0200
Ingo Molnar <mingo@xxxxxxx> wrote:

> 
> * Borislav Petkov <bp@xxxxxxxxx> wrote:
> 
> > +++ b/arch/x86/kvm/paging_tmpl.h
> > @@ -121,7 +121,7 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
> >  				    gva_t addr, u32 access)
> >  {
> >  	pt_element_t pte;
> > -	pt_element_t __user *ptep_user;
> > +	pt_element_t __user *uninitialized_var(ptep_user);
> 
> Note that doing this is actually actively dangerous for two reasons.
> 
> Firstly, it also shuts down the warning when it turns into a *real* 
> warning. For example this function will not produce a warning:
> 
>  int test(int a)
>  {
>         int uninitialized_var(b);
> 
>         return b;
>  }
> 
> Secondly, if the *compiler* cannot understand the flow then the code 
> is obviously rather complex for humans to review. So if there's an 
> initialization bug in the future, the risk of a human not seeing it 
> and the risk of uninitialized_var() hiding it is larger.
> 
> So the recommended thing is to simplify the flow there to make it 
> easier for the compiler to see through it.


Thank you for your advice.

Borislav, would you like to do the fix suggested here?

As the person who introduced this warning, if these are too many
for you, I will try some of these.

  Takuya
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux