Re: [PATCH] futex: s/0/NULL/ in pointer context

From: Arnd Bergmann
Date: Sun Jan 09 2005 - 09:28:03 EST


On Sünndag 09 Januar 2005 10:23, Alexey Dobriyan wrote:
> @@ -236,7 +236,7 @@
> */
> static inline void get_key_refs(union futex_key *key)
> {
> - if (key->both.ptr != 0) {
> + if (key->both.ptr != NULL) {
> if (key->both.offset & 1)
> atomic_inc(&key->shared.inode->i_count);
> else

Actually, many consider the preferred way to write this

if (key->both.ptr) {

instead, since the condition you want to check is 'is key->both.ptr
a valid pointer', not 'is key->both.ptr inequal to the invalid
pointer'. The normal use for NULL is only in assignments and
initializations, not in comparisons.

Arnd <><

Attachment: pgp00000.pgp
Description: signature