[U-Boot] [PATCH 1/2] Move uninitialized_var() macro from ubi_uboot.h to compiler.h

Albin Tonnerre albin.tonnerre at free-electrons.com
Tue Sep 1 20:52:33 CEST 2009


On Tue, Sep 01, 2009 at 10:25:18PM +0400, Anton Vorontsov wrote :
> On Tue, Sep 01, 2009 at 08:11:41PM +0200, Wolfgang Denk wrote:
> > Dear Anton Vorontsov,
> > 
> > In message <20090901165803.GA3668 at oksana.dev.rtsoft.ru> you wrote:
> > > This is needed so that we could use this macro for non-UBI code.
> > > 
> > > Signed-off-by: Anton Vorontsov <avorontsov at ru.mvista.com>
> > > ---
> > >  include/compiler.h  |    3 +++
> > >  include/ubi_uboot.h |    4 +---
> > >  2 files changed, 4 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/include/compiler.h b/include/compiler.h
> > > index 272fd3c..e602cce 100644
> > > --- a/include/compiler.h
> > > +++ b/include/compiler.h
> > > @@ -122,4 +122,7 @@ typedef unsigned int            uintptr_t;
> > >  
> > >  #endif
> > >  
> > > +/* compiler options */
> > > +#define uninitialized_var(x)		x = x
> > 
> > Please excuse my ignorance, but where and what for is such a
> > definition useful?
> 
> It's used to avoid GCC warnings, i.e. when GCC isn't smart enough
> to see that some variable isn't actually used uninitialized.
> 
> ~/linux-2.6$ git grep uninitialized_var drivers/ | wc -l
> 94

You seem to be grepping the linux source tree. The whole U-boot codebase
contains only 10 of them.

> We can fix the warnings by assigning some value to a variable
> at declaration, but the advantage of 'x = x' trick is that it
> doesn't generate any code.

I'm not quite sure that would be noticeable given the number of uses (I don't
have any opinion as to whether we should initialize them properly, though).

Regards,
-- 
Albin Tonnerre, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: Digital signature
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090901/72c28aed/attachment.pgp 


More information about the U-Boot mailing list