lkml.org 
[lkml]   [2011]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kvm: Fix build warnings

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

>
> * Borislav Petkov <bp@alien8.de> 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


\
 
 \ /
  Last update: 2011-05-31 10:19    [W:3.229 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site