Subject: Re: lib/1764: __ivaliduser() contains call to abort()
To: Christos Zoulas <christos@deshaw.com>
From: Chris G Demetriou <Chris_G_Demetriou@BALVENIE.PDL.CS.CMU.EDU>
List: netbsd-bugs
Date: 11/16/1995 19:58:25
> There is more code in the kernel that uses my pet peeve stylistic nono:
>
> value = !! expression;
>
> instead of:
>
> value = expression != 0;
>
> I hate to have to always have think about the double negation, but
> then I might be just dumb.
I agree with you here. the double negation does bad things to my eyes
and brain. 8-)
One bugger that i've seen at least one in the source tree is code
like:
int i;
i = foo & bar;
if (i) ...
if foo and bar are longs, and you're on a machine where sizeof(int) !=
sizeof(long) (say, and ALPHA! 8-), and the bits which are set in both
foo and bar are in the bits which don't exist in an int... you lose.
example: foo = bar = 0x10000000;
foo & bar = 0x100000000;
(int) (foo & bar) = 0;
moral of the story: always use (foo & bar) != 0, or == 0...
chris