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



In article <20150103134705.GX2079%apb-laptoy.apb.alt.za@localhost>,
Alan Barrett  <apb%cequrux.com@localhost> wrote:
>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".

Swapping them is a bad idea because it makes the function different than
the rest of the strtol family.

>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.

I am fine with that. Given that kamil's other functions can be implemented
easily with macros, I will commit in a couple of days if I don't hear
otherwise.

christos

christos



Home | Main Index | Thread Index | Old Index