Subject: Re: a few minor cleanups to src/share/misc/style
To: None <firstname.lastname@example.org, email@example.com>
From: Matthias Buelow <firstname.lastname@example.org>
Date: 03/23/2001 01:25:27
"Greg A. Woods" <email@example.com> writes:
> * Don't use `!' for tests unless it's a boolean.
A reasonable recommendation, imho...
> * E.g. use "if (*p == '\0')", not "if (!*p)".
>The test *is* boolean, damnit! :-)
look at it like this for once:
basically, the first expression says:
if dereferenced-pointer-value of p is the nul character, then ...
whereas the second expression says:
if not dereferenced-pointer-value of p is not integer zero, then ...
maybe you might understand why some people prefer the first expression,
even though the second is "faster to type".
(I personally prefer the order "'\0'==*p", for hopefully obvious reasons)