<<< Date Index >>>     <<< Thread Index >>>

Re: Little code cleanup



On Tue, Mar 04, 2008 at 06:30:48PM +0000, David Laight wrote:
> On Mon, Mar 03, 2008 at 11:08:34PM -0500, Derek Martin wrote:
> > On Tue, Mar 04, 2008 at 12:26:23AM +0100, Vincent Lefevre wrote:
> > > On 2008-03-03 17:42:01 +0100, S?bastien Hinderer wrote:
> > > > 2. It is true that testing pointers may avoid segfaults, but they don't
> > > > avoid problems. 
> > 
> > That really depends on whether the code is written such that it knows
> > whether the pointer should ever be null, and how the programmer decides
> > to deal with it when it is...  What you say is true sometimes, but
> > untrue often (if the code is well-written).  If the programmer can
> > know, for instance, that a null pointer in a particular place is
> > clearly a bug, then he could, for example, log a line to wherever
> > (stderr, some log file, etc.) which tells you what function was
> > executing when it happened (though this is tedious to maintain), what
> > source file and line number
> 
> Actually these are often easier to debug is the program is allowed
> to take the SIGSEGV and core dump.

The point is not whether segfaults are easier to debug (they are); the
point is that very often checking pointers can in fact avoid problems,
so long as the programmer detects and handles error conditions sanely.
Software should be written so that it is easy and comfortable to use
FIRST, and only then should issues of programming and debugging be
considered...

-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.

Attachment: pgps8rrvEKrkD.pgp
Description: PGP signature