Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Feb 1997 15:15:39 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        Arne.Juul@idt.ntnu.no, eivind@dimaga.com
Cc:        hackers@freebsd.org
Subject:   Re: NULL as ((void*)0) (was Re: strlen() question)
Message-ID:  <199702150415.PAA04061@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> I hereby propose changing the default declaration of NULL under FreeBSD from
>> #define NULL 0
>>  to
>> #define NULL ((void*)0)
>>  for better type-safety and ease of transition to other architechtures
>> ...

>This *shouldn't* help.  If it does, the code is broken.
>All code should do the right thing with varargs; if having NULL be
>plain 0 breaks it, so much the better :-)   Broken code should be
>found and fixed, not nurtured.

I like plain 0 as a default because it tends to expose broken code sooner.

>Ideally one should define NULL to plain 0 sometimes, to
>(void *)0  sometimes, and to (1-1)  (or some other bizarre but
>legal option) sometimes, just to find bugs in the source tree.

I did this for /usr/src/sys.  This trick is also useful for types
(if you want to see a lifetime's worth of bugs :-():
typedef signed char off_t; ... typedef long double off_t.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702150415.PAA04061>