Subject: Re: strtonum(3) in our libc
To: Jason Thorpe <firstname.lastname@example.org>
From: Mindaugas <email@example.com>
Date: 06/06/2006 00:33:51
Jason Thorpe <firstname.lastname@example.org> 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.
> 3- It does not handle unsigned conversions. If we're going to keep
> the same naming convention, it should be "strtoinum()" and "strtounum
> ()" (following strtoimax(3) and strotoumax(3)).
Well, sounds good.
> 4- It should not produce "long long" results. It should produce a
> "intmax_t" or "uintmax_t" (depending on if we're doing a signed or
> unsigned conversion).
> Furthermore, the way that the error string is optionally returned is
> not very internationalization-friendly.
Agree, it should return error codes instead of string.
> 2- It does not take a base argument.
Well, position explaination of OpenBSD folks starting here:
And I think here is the main problem. Main point of this function
addition is a compability purposes with OpenBSD and their projects
which uses it. Both the FreeBSD folks and we agree, that API could be
improved, but OpenBSD folks, as usually, don not. So at first we must
take a decision:
a) Improve this function and somehow stay compatible with original
b) Add the original function into the libc wihout changes, as FreeBSD
c) Do not add this function at all