Subject: sanity checking arguments to library functions...
To: None <tech-userlevel@netbsd.org>
From: Luke Mewburn <lukem@cs.rmit.edu.au>
List: tech-userlevel
Date: 04/13/1999 23:27:02
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)
i think this is a good idea, and unless it breaks standards, we should
do it. of course, people will complain about the performance hit and
the method of highlighting failure, so i suggest that the following
be done:
* all of this code would be #ifdef LIBC_DIAGNOSTIC
* have diagnostics one of:
- warn()
- syslog "function __file__ __line__ ..." (my preferred ;)
- nothing
* have the failure mode one of:
- return from function a failure code, but continue on
- exit(1)
- dump core using abort() (my preferred ;)
obviously, the diagnostics & failure mode has to be decided apon.
maybe that can be conditionally compiled in too based on the setting
of LIBC_DIAGNOSTIC?
if the general idea is that this is ok, i'll start on this in my
infinite spare time.
thoughts/comments/objections?
luke.