Re: [PATCH 1/6] staging: android: binder: Remove some funny && usage

From: Jeremy Fitzhardinge
Date: Wed Jun 17 2009 - 12:32:00 EST


On 06/17/09 09:08, Daniel Walker wrote:
On Wed, 2009-06-17 at 08:28 -0700, Jeremy Fitzhardinge wrote:
I have a general code-cleanup rule to
convert:

foo = false;
if (something_is_true())
foo = true;

to

foo = something_is_true();

Above seems more like a speed up, rather than a clean up. I would think
it's likely fine for a lot of cases tho.

The compiler should be smart enough to generate identical code in both cases. I think the second is better because it more directly expresses what you're trying to do: you have a boolean predicate, and you're assigning it to a boolean variable. The if() form has the same effect, but couches it in terms of control flow which is just obfuscation.

I was hoping Brian could explain this. I also added Arve (the author) to
the CC list. Maybe they can explain the purpose of the subsystem.

Also, what its usermode ABI is, how stable it is, whether its generally useful, does it have glibc/other library support, etc. Would you ever want to use this in a non-Android context?

Was this a recent change to C99, cause my compiler still doesn't know
about it .. I also see a couple places in the kernel where bool is
getting typedef'ed or somehow declared..

The C99 type has some stupid name like "_Bool", but the kernel typedefs it to bool everywhere.

J
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/