tech-userlevel archive

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

Re: strtonum(3) from OpenBSD?

On Sat, Jun 27, 2009 at 09:25:21AM +0100, Iain Hibbert wrote:
 >>>>>> If it *can* set errno on success, which is the usual convention for
 >>>>>> library functions,
 >>>>> Nonsense, that is no usual convention. Please read errno(2) and see what
 >>>>> it says (try the second paragraph in the DIAGNOSTICS section)
 >>>> Yes, precisely. Did you read your citation before posting it? (Or did
 >>>> you misunderstand what I wrote because you assumed I didn't know what
 >>>> I was talking about? :-p )
 >>> Yes I read it, can you explain how you translate "Successful calls never
 >>> set errno" into setting errno on success being the "usual convention"?
 >> Because "successful calls never set errno" is flatly wrong?
 > an exception does not make a convention.

The example I posted is not an exception; it's the usual behavior.

 > also since you appear to be pedantic, errno(2) does mention that it
 > relates to "system calls" and puts(3) is not actually a system call.

Neither is strtol, however.

 > Neither did it return an error indication, so the value of errno is moot.

That's the POINT. Calls that succeed may set errno anyway. You have to
check that an error occurred before inspecting errno.

The convention is that no (normal) call *clears errno to 0* on success.

A few calls that are specifically required to preserve the prior value
of errno on success. All others are free to leave trash behind, and
most do.

 > > and that's certainly a reasonable interpretation, but I'm not yet
 > > convinced it's the only possible interpretation.
 > perhaps its best to follow the reasonable interpretation rather than
 > striving to find another.

Unfortunately, when standards compliance is at issue, sanity has
little relevance.

David A. Holland

Home | Main Index | Thread Index | Old Index