Re: Strange interval arithmetic - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Strange interval arithmetic
Date
Msg-id 16807.1133469785@sss.pgh.pa.us
Whole thread Raw
In response to Re: Strange interval arithmetic  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
Greg Stark <gsstark@mit.edu> writes:
> Ah, I take back my taking back of this. It's still dicey to be doing it this
> way -- even if you reset errno before calling the library function.

See the rest of the thread.  The I-believe-what-I-read-in-the-spec camp
may take comfort from what it says in the SUS strtol spec,
http://www.opengroup.org/onlinepubs/007908799/xsh/strtol.html
The strtol() function will not change the setting of errno ifsuccessful.

Those who are disinclined to assume that implementations always follow
the spec may take comfort from the fact that we've been testing errno
only (without also inspecting the return value) in pg_atoi for years
without problems.

From neither point of view do I see an argument for adding a test on the
return value.  It's unnecessary according to the spec, and if you
disbelieve that strtol follows the spec, you should also be suspicious
about whether it's guaranteed to return LONG_MAX/LONG_MIN upon overflow
failure.  We have no track record that gives evidence that the latter is
universally true.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Strange interval arithmetic
Next
From: Michael Fuhr
Date:
Subject: Re: Strange interval arithmetic