Subject: Re: sanity checking arguments to library functions...
To: None <>
From: Giles Lean <>
List: tech-userlevel
Date: 04/14/1999 01:59:38
On Tue, 13 Apr 1999 23:27:02 +1000  Luke Mewburn wrote:

> an idea that came up a while ago was to add stuff to all libc functions
> to sanity check arguments (e.g, fgets(char *buf, int n, FILE *fp) having
> buf != NULL && fp != NULL, etc)

We do (null) already in printf.  The rot has kinda set in already. :-)

> 	* all of this code would be #ifdef LIBC_DIAGNOSTIC


Would this also be run time settable, i.e. if using a library with
LIBC_DIAGNOSTIC would the startup code also check for LIBC_DIAGNOSTIC
in the environment to tell if a process wants the checks?  And
possibly to choose between warnings and immediate failure?

> 		- syslog "function __file__ __line__ ..." (my
> 		preferred ;)

Better than warn().

> 	* have the failure mode one of:
> 		- dump core using abort() (my preferred ;)

If there is to be a failure mode, this is the one I like.  exit(1) is
frivolous -- it says nothing.