pgsql: Allow use of "z" flag in our printf calls, and use it where appr

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Allow use of "z" flag in our printf calls, and use it where appr
Дата
Msg-id E1W6Sbv-0001bt-2p@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Allow use of "z" flag in our printf calls, and use it where appropriate.

Since C99, it's been standard for printf and friends to accept a "z" size
modifier, meaning "whatever size size_t has".  Up to now we've generally
dealt with printing size_t values by explicitly casting them to unsigned
long and using the "l" modifier; but this is really the wrong thing on
platforms where pointers are wider than longs (such as Win64).  So let's
start using "z" instead.  To ensure we can do that on all platforms, teach
src/port/snprintf.c to understand "z", and add a configure test to force
use of that implementation when the platform's version doesn't handle "z".

Having done that, modify a bunch of places that were using the
unsigned-long hack to use "z" instead.  This patch doesn't pretend to have
gotten everyplace that could benefit, but it catches many of them.  I made
an effort in particular to ensure that all uses of the same error message
text were updated together, so as not to increase the number of
translatable strings.

It's possible that this change will result in format-string warnings from
pre-C99 compilers.  We might have to reconsider if there are any popular
compilers that will warn about this; but let's start by seeing what the
buildfarm thinks.

Andres Freund, with a little additional work by me

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/ac4ef637ad2ff2a24847f67d14027b8745f6741e

Modified Files
--------------
config/c-library.m4                       |   58 +++++++++++++++++++-----
configure                                 |   70 +++++++++++++++++++++++++----
configure.in                              |   12 ++++-
src/backend/access/common/indextuple.c    |    5 +--
src/backend/access/gin/ginentrypage.c     |    5 +--
src/backend/access/hash/hashinsert.c      |    5 +--
src/backend/access/heap/hio.c             |    7 ++-
src/backend/access/heap/rewriteheap.c     |    5 +--
src/backend/access/nbtree/nbtinsert.c     |    5 +--
src/backend/access/nbtree/nbtsort.c       |    5 +--
src/backend/access/spgist/spgdoinsert.c   |    6 +--
src/backend/access/spgist/spgutils.c      |   11 +++--
src/backend/access/transam/xlog.c         |    4 +-
src/backend/nodes/readfuncs.c             |   13 +++---
src/backend/port/sysv_shmem.c             |    8 ++--
src/backend/port/win32_shmem.c            |    4 +-
src/backend/storage/file/fd.c             |    2 +-
src/backend/storage/freespace/freespace.c |    3 +-
src/backend/storage/ipc/dsm.c             |    4 +-
src/backend/storage/ipc/dsm_impl.c        |   12 ++---
src/backend/storage/ipc/ipci.c            |    3 +-
src/backend/storage/ipc/shmem.c           |   14 +++---
src/backend/storage/lmgr/predicate.c      |    8 ++--
src/backend/utils/mmgr/aset.c             |   23 +++++-----
src/backend/utils/mmgr/mcxt.c             |   24 ++++------
src/include/pg_config.h.in                |    4 +-
src/port/snprintf.c                       |   26 +++++++++++
27 files changed, 221 insertions(+), 125 deletions(-)


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: pgsql: Fix alignment of GIN in-line posting lists stored in entry tuple
Следующее
От: Fujii Masao
Дата:
Сообщение: pgsql: Remove duplicate index entry DATE_TRUNC in document.