Subject: Re: NULL return value checking
To: None <gat7634@hotmail.com>
From: M. Warner Losh <imp@village.org>
List: tech-kern
Date: 04/23/2002 20:29:04
In message: <F147NovUKF7nXHBLzlc00005ded@hotmail.com>
            "Gary Thorpe" <gat7634@hotmail.com> writes:
: Assuming it is zero is technically incorrect. It *could* be non-zero, in 
: which case the resulting branch of the if() block would be different. Since 
: this is code which I assume is for the NetBSD kernel, then it only depends 
: on how NetBSD defines NULL.

That is not correct.

In C, comparison and assigment of pointers against the integer
constant 0, *IS* portable *ALWAYS*.  You have to do it in a pointer
context (eg char *p = 0 is always right, but bzero(&p, sizeof(p))
isn't).  NULL doesn't make it any more portable.

A NULL pointer can be NON-Zero, but the standard says that the
constructs that are the topic of this thread must work.

Warner