tech-userlevel archive

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

Re: strtonum(3) from OpenBSD?

Am 23.06.2009 um 17:29 schrieb Thor Lancelot Simon:

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

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.

like strsuftollx ?

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

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.

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

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

Thor Lancelot Simon
   "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