tech-userlevel archive

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

Re: strtonum(3) from OpenBSD?



On Wed, Jun 24, 2009 at 08:22:11AM +0200, Marc Balmer wrote:
>
>> Returning an error *string* is so profoundly bogus I have trouble
>> imagining that anyone with more than a few weeks' experience  
>> programming
>> in C doesn't see why.
>
> with even more experience in C you get to learn to actually look
> at implementations.  In the strtonum(3) case, you will spot that
> it actually sets errno _and_ provides a string value which can be
> used for most (simple and english) error message.

The function generates errno values which can't be used to
distinguish the error cases distinguished by the text strings,
which are (absurdly) specified in its manual page as part of the
API (in other words, the function as specified is inherently
non-localizable).

If it didn't set errno at all, it would be an example of really,
really bad API design.  Since it does (but doesn't do so usefully),
it's merely an example of bad API design.

This is NetBSD.  Cleanliness matters.  I'm opposed to adding this
API to the system in its current form.

And no, I don't care what the implementation looks like so long
as the defined API is so broken.  And -- no matter how loud and
outraged you get -- it's unlikely you'll persuade me otherwise.

Thor


Home | Main Index | Thread Index | Old Index