Re: refactoring basebackup.c (zstd workers)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: refactoring basebackup.c (zstd workers)
Дата
Msg-id 1565808.1647803514@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: refactoring basebackup.c (zstd workers)  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: refactoring basebackup.c (zstd workers)  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
>> Should this also set/check errno ?
>> And check if value != ivalue_endp ?
>> See strtol(3)

> Even after reading the man page for strtol, it's not clear to me that
> this is needed. That page represents checking *endptr != '\0' as
> sufficient to tell whether an error occurred.

I'm not sure whose man page you looked at, but the POSIX standard [1]
has a pretty clear opinion about this:

    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(), then check errno.

Checking *endptr != '\0' is for detecting whether there is trailing
garbage after the number; which may be an error case or not as you
choose, but it's a different matter.

            regards, tom lane

[1] https://pubs.opengroup.org/onlinepubs/9699919799/



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: refactoring basebackup.c (zstd workers)
Следующее
От: Justin Pryzby
Дата:
Сообщение: Re: refactoring basebackup.c (zstd workers)