Subject: Re: error handling functions again...
To: Elad Efrat <elad@NetBSD.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-userlevel
Date: 08/26/2006 01:02:41
On Aug 26,  2:39am, elad@NetBSD.org (Elad Efrat) wrote:
-- Subject: Re: error handling functions again...

| Christos Zoulas wrote:
| 
| > Based on suggestions from other people I have made the following changes
| > to the error handling wrappers:
| > 
| >   - moved the decls from <err.h> to <util.h>
| >   - don't print the strings
| >   - provide a function to control printing of errors.
| > 
| > The diff is on ftp://ftp.netbsd.org/pub/NetBSD/misc/christos/efun/
| > Please let me know what you think.
| 
| Looks great, except that you need to change ecalloc() to use calloc()
| rather than malloc(), otherwise you lose the integer overflow
| protection. Use this:
| 
| void *
| ecalloc(size_t n, size_t s)
| {
| 	void *p = calloc(n, s);
| 	if (p == NULL)
| 		(*efunc)(1, "Cannot allocate %zu bytes", n);
| 	return p;
| }
| 

Thanks, fixed.

christos