On 15/01/2017 22:43, Adrian Chadd wrote:
> On 15 January 2017 at 11:56, Ian Lepore <i...@freebsd.org> wrote:
> 
>>
>> What is the point of the !! in these macros?  The expressions already
>> have boolean type (even in C++ where it matters) due to the ==.
>>  Removing the !! would also make one level of parens redundant.
> 
> It's just a habit i picked up from linux-land. That way it really is
> only 1 or 0, so things like debugging output and such make easier
> sense.

Well, that habit is useful when applied to results of bit-wise operations.
It does nothing but obfuscating the code when applied to results of logical
operations.  Which is the case here.
And even with the bit-wise operation we have a FreeBSD idiom of comparing the
result with zero using != 0.  More verbose, but also more stylish.

> It's also fixed a handful of bugs in the past (but I can't think of
> exact cases right now) - primarily where other code expected 1 or 0
> (for things like shifts into protocol fields) and the macro returns 0
> or ${LARGEVAL}.


-- 
Andriy Gapon
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to