Re: Style question: Should one check for NULL pointers?

Alan Stern
2003-07-11T02:20:22Z

On Thu, 10 Jul 2003, Eli Carter wrote:

> Alan Stern wrote:
> [snip]
> > Ultimately this comes down to a question of style and taste. This
> > particular issue is not addressed in Documentation/CodingStyle so I'm
> > raising it here. My personal preference is for code that means what it
> > says; if a pointer is checked it should be because there is a genuine
> > possibility that the pointer _is_ NULL. I see no reason for pure
> > paranoia, particularly if it's not commented as such.
> >
> > Comments, anyone?
>
> BUG_ON() perhaps?

Not really needed, since a segfault will produce almost as much
information as a BUG_ON(). Certainly it will produce enough to let a
developer know that the pointer was NULL.

Alan Stern>