linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Oeser <ingo.oeser@informatik.tu-chemnitz.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Style question: Should one check for NULL pointers?
Date: Mon, 14 Jul 2003 00:53:10 +0200	[thread overview]
Message-ID: <20030714005310.G639@nightmaster.csn.tu-chemnitz.de> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0307101606060.22398-100000@netrider.rowland.org>; from stern@rowland.harvard.edu on Thu, Jul 10, 2003 at 04:28:09PM -0400

Hi,

On Thu, Jul 10, 2003 at 04:28:09PM -0400, Alan Stern wrote:
> There are many places in the kernel where a function checks whether a
> pointers it has been given is NULL.  Now sometimes this makes perfect
> sense because the function's description explicitly says that a NULL
> pointer argument is valid.  But in many, many cases (maybe even the
> majority) it is nothing more than paranoia: the pointer can never be NULL
> in a properly functioning system.

There are many meanings of NULL.

a) NULL -> I don't know
   Reaction: Ok, then do a generic/default variant.

b) NULL -> failure in caller passed down to us.
   Reaction: Pass it on, return -EINVAL or ignore the call

c) NULL -> failure in API (argument can't be NULL)
   Reaction: BUG_ON()
   
...

So the answer isn't only taste, it's a matter of simplicity and
roboustness.

Regards

Ingo Oeser

  parent reply	other threads:[~2003-07-13 22:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-10 20:28 Style question: Should one check for NULL pointers? Alan Stern
2003-07-10 20:52 ` Eli Carter
2003-07-10 22:12   ` H. Peter Anvin
2003-07-11  2:35   ` Alan Stern
2003-07-11 14:29     ` Eli Carter
2003-07-11 15:16       ` Alan Stern
2003-07-12 18:40         ` Horst von Brand
2003-07-13 21:42           ` Alan Stern
2003-07-11 20:33       ` H. Peter Anvin
2003-07-10 22:54 ` David D. Hagood
2003-07-11  4:02   ` Hollis Blanchard
2003-07-11  4:38   ` Hua Zhong
2003-07-11 14:13     ` David D. Hagood
2003-07-11 14:52       ` Richard B. Johnson
2003-07-11 15:39         ` Alan Stern
2003-07-11 19:32 ` Horst von Brand
2003-07-11 20:36   ` H. Peter Anvin
2003-07-11 21:21   ` Alan Stern
2003-07-13 22:53 ` Ingo Oeser [this message]
     [not found] <7QmZ.5RP.17@gated-at.bofh.it>
2003-07-10 21:00 ` Dennis Bliefernicht
2003-07-10 22:13   ` H. Peter Anvin
2003-07-10 22:28     ` Larry McVoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030714005310.G639@nightmaster.csn.tu-chemnitz.de \
    --to=ingo.oeser@informatik.tu-chemnitz.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).