Re: Remaining dependency on setlocale()

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Remaining dependency on setlocale()
Дата
Msg-id CA+TgmobJh2tUXS5joNaY5Y6LTiWdFst4bWy3kYECSTvtvk_pBg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Remaining dependency on setlocale()  (Joe Conway <mail@joeconway.com>)
Список pgsql-hackers
On Wed, Aug 7, 2024 at 9:42 AM Joe Conway <mail@joeconway.com> wrote:
> I guess in many/most places we use atoi we don't care, but maybe it
> matters for some?

I think we should move in the direction of replacing atoi() calls with
strtol() and actually checking for errors. In many places where use
atoi(), it's unlikely that the string would be anything but an
integer, so error checks are arguably unnecessary. A backup label file
isn't likely to say "START TIMELINE: potaytoes". On the other hand, if
it did say that, I'd prefer to get an error about potaytoes than have
it be treated as if it said "START TIMELINE: 0". And I've definitely
found missing error-checks over the years. For example, on pg14,
"pg_basebackup -Ft -Zmaximum -Dx" works as if you specified "-Z0"
because atoi("maximum") == 0. If we make a practice of checking
integer conversions for errors everywhere, we might avoid some such
silliness.

--
Robert Haas
EDB: http://www.enterprisedb.com



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