diff mbox

[U-Boot] Introduce a global bool type

Message ID 50EC79E1.1080802@freescale.com
State Not Applicable
Headers show

Commit Message

York Sun Jan. 8, 2013, 7:56 p.m. UTC
On 01/08/2013 11:07 AM, Wolfgang Denk wrote:
> Dear Timur Tabi,
> 
> In message <50EC5D29.1070408@freescale.com> you wrote:
>>
>>> _Bool has been introduced very late to any C standard, and you can
>>> still see this from the ugly, unnatural name.
>>
>> It was introduced in C99, which is over 12 years old.
> 
> And how old is C?   I think the "official" announcment was 1972, so
> that's more than twice as long without that addition.
> 
>>> work wit than a CLI.  And I've seen more than one case where bugs were
>>> caused by using "proper bool types" like this:
>>>
>>> 	i = 0;
>>> 	j = 0;
>>> 	k = 2;
>>>
>>> 	if ((i | j | k) == true) ...
>>
>> Ok, but this is just wrong.  i, j, and k are not boolean types, so they
>> should not be compared with 'true' or 'false'.  I don't think you'll find
>> any disagreement with that.
> 
> You are right.  And I wrote that it's a bug.  But this is what you can
> easily get from using boolean types.  This is example has not been
> invented by me.  I don't even claim that this was good programming
> style - all I want to say is that from what I have seen the boolean
> types are not a panacea; they cause new problems as well.
> 

No disagree. How shall we close this? Will some change like below
acceptable?


York

Comments

Wolfgang Denk Jan. 8, 2013, 9:39 p.m. UTC | #1
Dear York Sun,

In message <50EC79E1.1080802@freescale.com> you wrote:
>
> No disagree. How shall we close this? Will some change like below
> acceptable?
> 
> diff --git a/include/linux/types.h b/include/linux/types.h
> index 925ece7..f07ba41 100644
> --- a/include/linux/types.h
> +++ b/include/linux/types.h
> @@ -7,6 +7,7 @@
> 
>  #include <linux/posix_types.h>
>  #include <asm/types.h>
> +#include <stdbool.h>

Yes, but it needs to be tested that this is working for at least the
most popular tool chains, including when using USE_PRIVATE_LIBGCC.

>  #ifndef __KERNEL_STRICT_NAMES
> 
> @@ -113,10 +114,6 @@ typedef            __u64           u_int64_t;
>  typedef                __s64           int64_t;
>  #endif
> 
> -typedef _Bool bool;
> -#define false 0
> -#define true 1
> -

Yes, but similar removals are needed in a nomber of other header
files as well.

Best regards,

Wolfgang Denk
York Sun Jan. 8, 2013, 9:43 p.m. UTC | #2
On 01/08/2013 01:39 PM, Wolfgang Denk wrote:
> Dear York Sun,
> 
> In message <50EC79E1.1080802@freescale.com> you wrote:
>>
>> No disagree. How shall we close this? Will some change like below
>> acceptable?
>>
>> diff --git a/include/linux/types.h b/include/linux/types.h
>> index 925ece7..f07ba41 100644
>> --- a/include/linux/types.h
>> +++ b/include/linux/types.h
>> @@ -7,6 +7,7 @@
>>
>>  #include <linux/posix_types.h>
>>  #include <asm/types.h>
>> +#include <stdbool.h>
> 
> Yes, but it needs to be tested that this is working for at least the
> most popular tool chains, including when using USE_PRIVATE_LIBGCC.

Who can help here? I don't have the setup for other than powerpc.

> 
>>  #ifndef __KERNEL_STRICT_NAMES
>>
>> @@ -113,10 +114,6 @@ typedef            __u64           u_int64_t;
>>  typedef                __s64           int64_t;
>>  #endif
>>
>> -typedef _Bool bool;
>> -#define false 0
>> -#define true 1
>> -
> 
> Yes, but similar removals are needed in a nomber of other header
> files as well.
> 
Yes. I have those in my local tree.

York
Scott Wood Jan. 8, 2013, 9:46 p.m. UTC | #3
On 01/08/2013 03:43:34 PM, York Sun wrote:
> On 01/08/2013 01:39 PM, Wolfgang Denk wrote:
> > Dear York Sun,
> >
> > In message <50EC79E1.1080802@freescale.com> you wrote:
> >>
> >> No disagree. How shall we close this? Will some change like below
> >> acceptable?
> >>
> >> diff --git a/include/linux/types.h b/include/linux/types.h
> >> index 925ece7..f07ba41 100644
> >> --- a/include/linux/types.h
> >> +++ b/include/linux/types.h
> >> @@ -7,6 +7,7 @@
> >>
> >>  #include <linux/posix_types.h>
> >>  #include <asm/types.h>
> >> +#include <stdbool.h>
> >
> > Yes, but it needs to be tested that this is working for at least the
> > most popular tool chains, including when using USE_PRIVATE_LIBGCC.
> 
> Who can help here? I don't have the setup for other than powerpc.

http://marc.info/?l=u-boot&m=132164771013203&w=1

-Scott
diff mbox

Patch

diff --git a/include/linux/types.h b/include/linux/types.h
index 925ece7..f07ba41 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -7,6 +7,7 @@ 

 #include <linux/posix_types.h>
 #include <asm/types.h>
+#include <stdbool.h>

 #ifndef __KERNEL_STRICT_NAMES

@@ -113,10 +114,6 @@  typedef            __u64           u_int64_t;
 typedef                __s64           int64_t;
 #endif

-typedef _Bool bool;
-#define false 0
-#define true 1
-
 #endif /* __KERNEL_STRICT_NAMES */

 /*