[U-Boot] [PATCH] Introduce a global bool type

Scott Wood scottwood at freescale.com
Mon Jan 7 23:50:52 CET 2013


On 01/07/2013 04:39:42 PM, Wolfgang Denk wrote:
> Dear York Sun,
> 
> In message <1357596628-27501-1-git-send-email-yorksun at freescale.com>  
> you wrote:
> > 'bool' is defined in random places. This patch consolidates them  
> into a
> > single typedef.
> 
> Has this been actually compile tested?
> 
> ...
> > --- a/include/linux/types.h
> > +++ b/include/linux/types.h
> > @@ -113,6 +113,8 @@ typedef		__u64		u_int64_t;
> >  typedef		__s64		int64_t;
> >  #endif
> >
> > +typedef _Bool bool;
> 
> And what exactly would "_Bool" be?

It's a standard C99 type (as is bool, but _Bool comes directly from the  
compiler rather than from headers).

> ...
> > --- a/include/xyzModem.h
> > +++ b/include/xyzModem.h
> > @@ -97,11 +97,6 @@ typedef struct {
> >  #endif
> >  } connection_info_t;
> >
> > -#ifndef	BOOL_WAS_DEFINED
> > -#define BOOL_WAS_DEFINED
> > -typedef unsigned int bool;
> > -#endif
> > -
> >  #define false 0
> >  #define true 1
> 
> And don't these remaining definitions of "false" and "true" cause
> nasty build errors somewhere?

Yes, the definition of true/false needs to move along with the  
definition of bool.

> This seems broken to me.  Can we rather try8 and get rid of all this
> "bool" stuff instead?  It's just obfuscating the code...

That's obviously a matter of opinion (I think "bool" is clearer than  
"int"), but I'd like to point out that Linux's use of bool has been  
growing, and U-Boot often borrows code from Linux...

Also, FWIW the compiler will generally allocate only one byte for a  
built-in boolean, so there is a minor run-time benefit in some  
situations.

-Scott


More information about the U-Boot mailing list