Subject: Re: NULL return value checking
To: None <>
From: M. Warner Losh <>
List: tech-kern
Date: 04/23/2002 20:29:04
In message: <>
            "Gary Thorpe" <> 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.