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

Måns Rullgård mans at mansr.com
Tue Jan 22 13:59:11 CET 2013


Albert ARIBAUD <albert.u.boot at aribaud.net> writes:

> Hi Måns,
>
>> In other words, boolifying on use rather than on assignment is generally
>> safer and usually at least as efficient.
>
> Except when assigning a C = A & B where A and B happen to have
> no common bit set. Which is why I think 'boolifying' as soon as
> possible -- on assignment -- is way safer than on use.

But that's not a boolean context.  You should use A && B.

The thing is, when using a value, you know if you need a boolean, but
not necessarily (easily) how the value was assigned.  Conversely, when
assigning a value, you do not know how it will be used.  By always
boolifying on use, you remove the need to keep track of which values are
"true" booleans and which ones are arbitrary values (or even pointers)
you happen to be using in a boolean fashion.

-- 
Måns Rullgård
mans at mansr.com


More information about the U-Boot mailing list