On Mon, Dec 29, 2014 at 11:00 PM, <Valdis.Kletnieks@xxxxxx> wrote: > 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.... > In fact, to be sure that I was not messing around I was thinking in write a Clang plugin for doing so. With this I can be 100% sure that I am not introducing any errors. But anyway if there is no benefits on doing so there is no need to do. -- Simplicity is the ultimate sophistication _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies