tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Reuse strtonum(3) and reallocarray(3) from OpenBSD

I know this comment is a week late.

On Sat, 27 Dec 2014, Christos Zoulas wrote:
* - Always returns numbers in range. Errors are indicated in *rerror:
*	- 0       -> OK
*	- ENOTSUP -> the string conversion was incomplere
*	- EINVAL  -> the base was not supported
*	- ERANGE  -> the value returned from the conversion was out of range
*		     and was corrected to be in range.

I understand the desire to have different error returns for all those
cases, but ENOTSUP doesn't seem right for "the string argument doesn't
make sense".  I'd be inclined to swap them: ENOTSUP for "the requested
base is not supported" and EINVAL for "the string does not represent a
valid number in the specified base".

Just using EINVAL for both cases also doesn't seem too bad.  Ordinarily,
the base will be specified by the programmer, and will be valid, so the
only thing that's likely to beinvalid is the string.

--apb (Alan Barrett)

Home | Main Index | Thread Index | Old Index