Messages in this thread | | | Date | Fri, 01 Apr 2011 17:07:20 -0700 (PDT) | Subject | Re: [PATCH 02/17] mm: mmu_gather rework | From | David Miller <> |
| |
From: Linus Torvalds <torvalds@linux-foundation.org> Date: Fri, 1 Apr 2011 09:13:51 -0700
> What's the difference? Integer assignment makes a hell of a difference. Do this: > > long long expression = ... > ... > bool val = expression; > > and depending on implementation it will either just truncate the value > to a random number of bits, or actually do a compare with zero.
But note that, as you indicate, using int's to store boolean values have this exact problem.
And most of the time people are converting an "int used as a boolean value" into a "bool".
At least the "bool" has a chance of giving true boolean semantics in the case you describe, whereas the 'int' always has the potential truncation issue.
So, personally, I see it as a net positive to convert int to bool when the variable is being used to take on true/false values.
| |