lkml.org 
[lkml]   [2011]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] arm: nomadik: avoid assigning u32 to bool
>> Why?  There are dozens of places in the kernel where this done, the code
>> generated should be the same, and it's pretty obvious what is being done
>> as it is.
>
> Primarily because we were asked to avoid casts to bool even if
> they are safe.

[I have studied, meanwhile]

Actually the point of Rabin is, I think, that the patch is not needed.
Our "bool" is the C99 "_Bool" type, for which the compiler
automatically converts all non-0 assignments to 1. Even if storage
is still one byte.

IIUC, the point of _Bool is allowing comparisong with "true", while in
general non-0 is considered true if evaluated in a conditional
but may be "!= 1" so "!= true" if compared explicitly.

You can compile a one-liner to check. I used a few more:

_Bool i[10];

int main(void)
{
i[0] = 1;
i[1] = 10;
return i[0];
}

/alessandro


\
 
 \ /
  Last update: 2011-04-03 12:57    [W:0.041 / U:0.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site