Re: Strange interval arithmetic

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Strange interval arithmetic
Дата
Msg-id 20051201204538.GA68332@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Strange interval arithmetic  (Greg Stark <gsstark@mit.edu>)
Список pgsql-hackers
On Thu, Dec 01, 2005 at 03:31:41PM -0500, Greg Stark wrote:
> Greg Stark <gsstark@MIT.EDU> writes:
> > Generally speaking looking at errno when you haven't received an error return
> > from a libc function is asking for trouble. It could be leftover from any
> > previous libc error. 
> > 
> > That's how you get programs saying things like "strtol: No such file or
> > directory" ...
> 
> 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.
> 
> The problem is that the function can call other libc functions, which may in
> turn return errors. But these errors might be incidental and handled by the
> function you're calling.

I had that concern, as I've seen such incidental errno changes
before.  But Tom pointed out the following from SUS:
 The strtol() function shall not change the setting of errno if successful.

Immediately after that the standard says:
 Since 0, {LONG_MIN} or {LLONG_MIN}, and {LONG_MAX} or {LLONG_MAX} are returned on error and are also valid returns on
success,an application wishing to check for error situations should set errno to 0, then call strtol() or strtoll(),
thencheck errno.
 

I don't know if any systems are non-compliant in this respect, but
Tom said that "we've been doing it that way (errno test only) for
many years without complaints."

-- 
Michael Fuhr


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Strange interval arithmetic
Следующее
От: Greg Stark
Дата:
Сообщение: Re: generalizing the planner knobs