tech-userlevel archive

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

Re: strtonum(3) from OpenBSD?



Thor,

On Tue, Jun 23, 2009 at 05:21:49PM +0200, Marc Balmer wrote:

Am 23.06.2009 um 17:15 schrieb Thor Lancelot Simon:

On Tue, Jun 23, 2009 at 05:06:29PM +0200, Marc Balmer wrote:

Yes, already more than one program apparently use it.  And at least
one
more once we have it ;)

Oh, my god, three programs use this bogus interface.  That by itself
must be a reason to check it in!

care to elaborate a bit (on a technical level, if possible) why you find
this interface bogus?


thank you for elaborating a bit on why you called strtonum(3) bogus.
I have added my comments inline.

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.

1) You can't switch on an error string, so you can't really ever
  programmatically do anything smart in response to failure.

Why on earth to want to switch on the error string when strtonum(3)
comfortably sets errno?

2) If the error string is made a defined part of the interface, so that
  programs can "switch" on it using strcmp (UGH!), then the function
  becomes inherently non-localizable.

Why on earth to want to switch on the error string using strcmp when
strtonum(3) comfortably sets errno?

3) We already have defined errno values for all the error cases this
function can reasonably be expected to encounter if properly written.

The function is properly written, I think.  These guys who wrote it
were not amateurs either.  But you failed to look at the actual
implementation...

"OpenBSD did it" is no more reason to dirty up our libc with this kind
of ill-considered interface than "SCO Xenix did it". NetBSD libc should not be the union of every mistake anyone ever made in libc in any version
of Unix.

I *NEVER* mentioned the OpenBSD origin as a *REASON* to have it.
I just asked for a technical reasoning why not have a function that is
used in several places in a library, and ideally in the same library as
other OS'es put it.  I think that is a reasonable question.

<mirror>
Oh, you use strong words, given that you did not even look at the
implementation.

You call it "dirt", "a mistake", "ill considered", do a comparison with
Xenix, wihtout even looking at the code in question...  How can I
classify your arguments as anything other than an uninformed rant?
</mirror>

Si tacuisses.... ;)

- Marc Balmer


--
Thor Lancelot Simon tls%rek.tjls.com@localhost
   "Even experienced UNIX users occasionally enter rm *.* at the UNIX
    prompt only to realize too late that they have removed the wrong
    segment of the directory structure." - Microsoft WSS whitepaper



Home | Main Index | Thread Index | Old Index