Subject: Re: strtonum(3) in our libc
To: Mindaugas <>
From: Jason Thorpe <>
List: tech-userlevel
Date: 06/05/2006 16:00:13
On Jun 5, 2006, at 2:33 PM, Mindaugas wrote:

> Jason Thorpe <> wrote:
>> 1- How do you do error detection?  Looks like you check for return
>> value of zero and a non-zero errno?  This is bogus.  It should
>> return 0 on success and an error code on failure.  The result should
>> be passed back by the caller providing a pointer.
> We should check the **errstrp value. If NULL - we have an error.
> Passing back the result with a pointer (and returning error code)  
> could
> be more rational, but in fact, there are no technically difference
> between these ways.

Presumably, you mean:

	result = strtonum(..., &errstr);
	if (errstr != NULL) {
		/* Error. */

It looked to me like the errstrp argument was treated as optional in  
the strtonum() that you posted.  If so, this is just another example  
of poor API design on the part of OpenBSD.

-- thorpej