[Asterisk-Dev] "true" is -1 or 1 in boolean functions ?
Luigi Rizzo
rizzo at icir.org
Mon Jan 16 03:59:54 MST 2006
i notice some inconsistency in the return values for
functions that have a boolean result - some pieces of code
use -1, others use 1.
I am totally neutral on the topic, but would like if someone
could put a note in the CODING-GUIDELINES on which one is
the recommended method, because mixing the two things is
confusing and error prone, as:
- people looking at the code might think that the difference
means something other than the habit of the original coder;
- people using these functions might do odd things such
as a bitwise AND on the result of such functions and other
operands, which has different results depending on whether -1
or 1 is used (i think i have seen such instances in the code,
sometimes it is convenient, althoguh obfuscating);
thanks
luigi
More information about the asterisk-dev
mailing list