On Mon, 29 Dec 2014 22:25:41 -0200, Vinícius Tinti said:

> I was looking the kernel source code and there are a lot of places in
> which either "(expression) ? 1 : 0" or "(expression) ? 0 : 1" appear.
> As fair as I can tell both can be replaced by "!!expression" and
> "!expression".

As far as the compiler goes, they're the same thing, as you already discovered.

Some are just code written by not-so-experts.

In other cases, the author may have wanted to keep clear that we were
calculating an integer to be used for further arithmetic rather than a boolean.

Patches to clean it up wouldn't be a bad idea in some cases.  However, each
location will have to be examined for what was intended and what produces more
readable code.  If you're *really* ambitious, converting stuff to use a boolean
rather than an int where appropriate would be nice - we don't do that enough
currently. But that will require actually reading and understanding the code.
That's not a good task for those who like to submit patches without
thinking....

Attachment: pgpTXCUH9qB2K.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
[email protected]
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to