Subject: Re: NULL return value checking
To: None <>
From: None <>
List: tech-kern
Date: 04/23/2002 14:10:18
At Tue, 23 Apr 2002 20:36:57 +0000 (UTC), "Matthew Mondor" wrote:
> Thing is I have written all my code for years using boolean checking
> for NULL without problem, and was wondering if there were
> architecture-specific problems at times, as NetBSD's style file was
> the only document I found encourageing to use explicit NULL
> testing...

"Look around some more."  8-)

For instance, the GNU coding standards say:

> Try to avoid assignments inside if-conditions. For example, don't
> write this: 
> if ((foo = (char *) malloc (sizeof *foo)) == 0)
>   fatal ("virtual memory exhausted");
> instead, write this: 
> foo = (char *) malloc (sizeof *foo);
> if (foo == 0)
>   fatal ("virtual memory exhausted");

(Sure, that's not _actually_ a check against NULL, but it's an
explicit test separate from the assignment, with the same intent an
effect as a check against "NULL".)