pgsql: Suppress compiler warnings in new pgstats code.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Suppress compiler warnings in new pgstats code.
Дата
Msg-id E1pWlsH-00128s-0z@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Suppress compiler warnings in new pgstats code.

Some clang versions whine about comparing an enum variable to
a value outside the range of the enum, on the grounds that the
result must be constant.  In the cases we fix here, the loops
will terminate only if the enum variable can in fact hold a
value one beyond its declared range.  While that's very likely
to always be true for these enum types, it still seems like a
poor coding practice to assume it; so use "int" loop variables
instead to silence the warnings.  (This matches what we've done
in other places, for example loops over the range of ForkNumber.)

While at it, let's drop the XXX_FIRST macros for these enums and just
write zeroes for the loop start values.  The apparent flexibility
seems rather illusory given that iterating up to one-less-than-
the-number-of-values is only correct for a zero-based range.

Melanie Plageman

Discussion: https://postgr.es/m/20520.1677435600@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/728560db7d868b3ded9a8675742083ab89bcff7c

Modified Files
--------------
src/backend/utils/activity/pgstat_io.c | 17 ++++++-----------
src/backend/utils/adt/pgstatfuncs.c    | 10 ++++------
src/include/pgstat.h                   |  3 ---
3 files changed, 10 insertions(+), 20 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Harden postgres_fdw tests against unexpected cache flushes.
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Rework pg_input_error_message(), now renamed pg_input_error_info