linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Larry McVoy <lm@bitmover.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Style question: Should one check for NULL pointers?
Date: Thu, 10 Jul 2003 15:28:08 -0700	[thread overview]
Message-ID: <20030710222808.GA19308@work.bitmover.com> (raw)
In-Reply-To: <bekof0$g7i$1@cesium.transmeta.com>

On Thu, Jul 10, 2003 at 03:13:52PM -0700, H. Peter Anvin wrote:
> Followup to:  <3F0DD3FD.3030403@triphoenix.de>
> By author:    Dennis Bliefernicht <itsme.nospam@triphoenix.de>
> In newsgroup: linux.dev.kernel
> > 
> > The problem is IMHO code where some pretty fragile things are handled, 
> > especially file systems. I'd say: DO the paranoia checks if some fragile 
> > things are involved like key structures of the file system that can take 
> > _permanent_ damage. If you check for a NULL pointer you still have the 
> > chance to properly leave the system in a consistent state and no user 
> > will be happy if his filesystem goes messy just because someone saved a 
> > check to have nicer code, even if the original of the NULL pointer 
> > wasn't his fault, even if it's a developing version. So if the check 
> > isn't a total performace disaster, do it whenever permanent damage could 
> > occur.
> > 
> 
> Actually, you have it somewhat backwards.
> 
> In most cases, checking for NULL pointers (and returning an error
> whatnot) is actually *more* likely to cause permanent damage than
> having the kernel bomb out.  At least with the kernel bombing out you
> won't keep grinding on a filesystem for which your kernel
> datastructures are bad.  This is *IMPORTANT*.

In BK, we have a READ_ONLY flag on each revision history file.  Whenever
we get into a state where we don't understand what's going on, we set that
flag.  That flag is checked in the code path which writes the file and it
will simply refuse the write the file if the flag is set.

Seems like the same idea would work here.  I can imagine a lot of use for
a file system which remounts itself as read only the second it sees a 
problem it can't handle.  At least you can poke around and try and figure
out what is going on.
-- 
---
Larry McVoy              lm at bitmover.com          http://www.bitmover.com/lm

  reply	other threads:[~2003-07-10 22:15 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <7QmZ.5RP.17@gated-at.bofh.it>
2003-07-10 21:00 ` Style question: Should one check for NULL pointers? Dennis Bliefernicht
2003-07-10 22:13   ` H. Peter Anvin
2003-07-10 22:28     ` Larry McVoy [this message]
2003-07-10 20:28 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

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=20030710222808.GA19308@work.bitmover.com \
    --to=lm@bitmover.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    /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).