pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.
Date: Fri, 20 Feb 2015 05:12:00 +0000
Message-ID: <E1YOfse-0003eE-Jq@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (9+ messages)  latest in thread

Message-ID: <E1YOfse-0003eE-Jq@gemulon.postgresql.org>
Permalink:  ../E1YOfse-0003eE-Jq@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1YOfse-0003eE-Jq@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.
  In-Reply-To: <E1YOfse-0003eE-Jq@gemulon.postgresql.org>
  References: <E1YOfse-0003eE-Jq@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox