[Eug-lug] LP64

T. Joseph CARTER knghtbrd at bluecherry.net
Thu Jan 13 01:51:49 PST 2005


On Mon, Jan 10, 2005 at 04:38:11PM -0800, Bob Miller wrote:
> > the thing is, there's also a foo_open function, that returns a
> > pointer to a struct.  the code was apparently written to make
> > open and ibp_open interchangable.  since they have different
> > return types, the author chose to use (void *).  the only use
> > of data is "if(!data) { ... }".
> 
> And that's wrong too.  Zero is a valid file descriptor, but not
> a valid pointer.  Never mind that if you never pass the descriptor
> to close(), you have a descriptor leak.

I had someone insist that 0 was mandated to be acceptable in place of
NULL.  I pointed out that 0 is a valid address on some systems, and was
answered that it was not a valid address in C, even on those systems.

I tend to fix code which uses 0 where NULL is intended when I can, but
there's so much of it exists!


More information about the EUGLUG mailing list