pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.
Дата
Msg-id E1YOfse-0003eE-Jq@gemulon.postgresql.org
обсуждение исходный текст
Ответы Re: pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.  (Andres Freund <andres@2ndquadrant.com>)
Список pgsql-committers
Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.

Replace some bogus "x[1]" declarations with "x[FLEXIBLE_ARRAY_MEMBER]".
Aside from being more self-documenting, this should help prevent bogus
warnings from static code analyzers and perhaps compiler misoptimizations.

This patch is just a down payment on eliminating the whole problem, but
it gets rid of a lot of easy-to-fix cases.

Note that the main problem with doing this is that one must no longer rely
on computing sizeof(the containing struct), since the result would be
compiler-dependent.  Instead use offsetof(struct, lastfield).  Autoconf
also warns against spelling that offsetof(struct, lastfield[0]).

Michael Paquier, review and additional fixes by me.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/09d8d110a604e52216102e73fb8475b7aa88f1d1

Modified Files
--------------
contrib/cube/cubedata.h                     |   15 +++++++--------
contrib/intarray/_int.h                     |    4 ++--
contrib/ltree/ltree.h                       |   14 +++++++-------
contrib/pageinspect/rawpage.c               |    2 +-
contrib/pg_trgm/trgm.h                      |    2 +-
src/backend/catalog/namespace.c             |   13 +++++++------
src/backend/commands/prepare.c              |    5 ++---
src/backend/executor/functions.c            |    6 +++---
src/backend/executor/spi.c                  |    5 ++---
src/backend/nodes/params.c                  |    5 ++---
src/backend/postmaster/syslogger.c          |    4 ++--
src/backend/tcop/postgres.c                 |    5 ++---
src/backend/utils/adt/geo_ops.c             |   22 +++++++++++-----------
src/backend/utils/cache/catcache.c          |    2 +-
src/bin/pg_dump/dumputils.c                 |    3 +--
src/bin/pg_dump/dumputils.h                 |    2 +-
src/include/access/gin_private.h            |    4 ++--
src/include/access/gist_private.h           |    7 ++++---
src/include/access/heapam_xlog.h            |    2 +-
src/include/access/spgist_private.h         |   10 +++++-----
src/include/access/xact.h                   |    8 ++++----
src/include/c.h                             |    8 ++++----
src/include/catalog/namespace.h             |    4 ++--
src/include/commands/dbcommands.h           |   15 ---------------
src/include/commands/tablespace.h           |    2 +-
src/include/executor/hashjoin.h             |    2 +-
src/include/nodes/bitmapset.h               |    4 ++--
src/include/nodes/params.h                  |    2 +-
src/include/nodes/tidbitmap.h               |    4 ++--
src/include/postgres.h                      |    8 ++++----
src/include/postmaster/syslogger.h          |    2 +-
src/include/replication/walsender_private.h |    4 ++--
src/include/storage/bufpage.h               |    2 +-
src/include/storage/fsm_internals.h         |    2 +-
src/include/storage/standby.h               |    4 ++--
src/include/tsearch/dicts/regis.h           |    2 +-
src/include/tsearch/dicts/spell.h           |    6 +++---
src/include/tsearch/ts_type.h               |    6 +++---
src/include/utils/catcache.h                |    4 ++--
src/include/utils/datetime.h                |    4 ++--
src/include/utils/geo_decls.h               |    4 ++--
src/include/utils/jsonb.h                   |    2 +-
src/include/utils/relmapper.h               |    2 +-
src/include/utils/varbit.h                  |    3 ++-
44 files changed, 109 insertions(+), 127 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Add pg_stat_get_snapshot_timestamp() to show statistics snapshot
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Use "#ifdef CATALOG_VARLEN" to protect nullable fields of pg_aut