[Asterisk-Dev] "true" is -1 or 1 in boolean functions ?
    Tilghman Lesher 
    tilghman at mail.jeffandtilghman.com
       
    Mon Jan 16 12:38:22 MST 2006
    
    
  
On Monday 16 January 2006 04:59, Luigi Rizzo wrote:
> 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);
Please show me how you can bitwise AND these two numbers and
come up with zero.  The only thing that matters is that the result is
always non-zero.  There simply isn't an error that can be generated
by mixing these two numbers.
-- 
Tilghman
    
    
More information about the asterisk-dev
mailing list