warning question

Joel Sherrill joel.sherrill at OARcorp.com
Mon May 11 20:11:05 UTC 2009


Arnout Vandecappelle wrote:
> On Wednesday 06 May 2009 17:49:28 Joel Sherrill wrote:
>   
>> Hi,
>>
>> I am looking at warnings and wondered if someone
>> could figured this one out.
>>
>> c/src/libchip/network/i82586.c:1722: warning: suggest parentheses around
>> operand of '!' or change '|' to '||' or '!' to '~'
>>
>> The code is clearly questionable IMO. ;)
>>
>>   *IE_CMD_CFG_PROMISC(buf)   = !!promiscuous | manchester << 2;
>>     
>
>  This means (!!promiscuous) | (manchester << 2).  It looks OK to me, though 
> adding parenthases around as I did certainly makes things clearer.
>
>  The !! is a trick to make sure you have a 1, not just any non-zero int.
>
>   
Thanks.  Ugly code I never would have written.  I have
committed this and given the credit to you with a link
to this thread.

Thanks
>  Regards,
>  Arnout
>   


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985





More information about the users mailing list