Re: printf format selection vs. reality

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: printf format selection vs. reality
Дата
Msg-id 20180523201046.4znqfw52bmr6o3gr@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: printf format selection vs. reality  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: printf format selection vs. reality  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 2018-May-23, Tom Lane wrote:

> The practical alternatives seem to be to avoid %z in frontend code,
> or to invent a macro SIZE_T_MODIFIER and use it like INT64_MODIFIER.
> Either one will be extremely error-prone, I'm afraid, unless we can
> find a way to get compiler warnings for violations.

Usage of %z outside safe-known seems really limited.  It would be sad to
force SIZE_T_MODIFIER for elog calls (where it is prevalent) just for
the benefit of usage outside of elog on fringe platforms -- you're right
that we do have a few cases of %z under fprintf() already.  The good
news is that AFAICS those strings are not translatable today, so
changing only those to SIZE_T_MODIFIER (and leaving alone those using
elog) is maybe not such a big deal.  I think those are dshash.c, dsa.c,
slab.c and aset.c only.

(I assume without checking that with the stringinfo API it's OK to use %z).

Can't we raise warnings on such usages with an archetype change?  (Hm,
is it possible to change archetype for fprintf?)

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: [PATCH v14] GSSAPI encryption support
Следующее
От: Tom Lane
Дата:
Сообщение: Re: printf format selection vs. reality