Source-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/sys/ufs/ffs
On Fri, Dec 26, 2008 at 9:16 AM, Luke Mewburn <lukem%netbsd.org@localhost>
wrote:
> On Thu, Dec 25, 2008 at 05:47:47PM -0500, Arnaud Lacombe wrote:
> | btw, don't test pointer truth, do the test against NULL. Setting NULL
> | to something else than 0 would be really fun :/
>
> That doesn't matter; see the following for an explanation:
> http://c-faq.com/null/ptrtest.html
>
You should have pointed me that NULL with a value other than 0 break
the C standard :)
Anyway, I'm just asking to stick to KNF, it's not so hard to respect
and makes code clearer:
/*
* Casts and sizeof's are not followed by a space. NULL is any
* pointer type, and doesn't need to be cast, so use NULL instead
* of (struct foo *)0 or (struct foo *)NULL. Also, test pointers
* against NULL. I.e. use:
*
* (p = f()) == NULL
* not:
* !(p = f())
*
* Don't use `!' for tests unless it's a boolean.
* E.g. use "if (*p == '\0')", not "if (!*p)".
- Arnaud
Home |
Main Index |
Thread Index |
Old Index