I usually without the == in these cases:
if (pointer) // test for non-0.
if (condition)
if (condition-valued-variable)
but not in these (although I am not very consistent):
if (integer != 0)
if (char != 0)
When using bool, I'm happy to write "if (X)" where X is a truth value
indicating a condition that has been tested, but if X were used as an
enumeration of truth values e.g. as in a theorem prover or a logic
simulator, I would tend to write ==, for example:
if (X == true && ptr && *ptr > 1)
The point being to illustrate the intent of the test (i.e. is it a
boolean test or a comparison against a point in a range of values), not
simply for it to be semantically correct.
Just to break that rule, however, if p were a pointer and x were an
integer, I would write:
x = (p != 0);
rather than
x = p;
:-)
enjoy,
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/