Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 20 Feb 2015 05:11:42 +0000 (00:11 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 20 Feb 2015 05:11:42 +0000 (00:11 -0500)
commit09d8d110a604e52216102e73fb8475b7aa88f1d1
tree6ffdaba34c52c319aa32b3cb95cc93cdcefb6d65
parent2fb7a75f37d0beca80f45e15736ec8d50064228a
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.
44 files changed:
contrib/cube/cubedata.h
contrib/intarray/_int.h
contrib/ltree/ltree.h
contrib/pageinspect/rawpage.c
contrib/pg_trgm/trgm.h
src/backend/catalog/namespace.c
src/backend/commands/prepare.c
src/backend/executor/functions.c
src/backend/executor/spi.c
src/backend/nodes/params.c
src/backend/postmaster/syslogger.c
src/backend/tcop/postgres.c
src/backend/utils/adt/geo_ops.c
src/backend/utils/cache/catcache.c
src/bin/pg_dump/dumputils.c
src/bin/pg_dump/dumputils.h
src/include/access/gin_private.h
src/include/access/gist_private.h
src/include/access/heapam_xlog.h
src/include/access/spgist_private.h
src/include/access/xact.h
src/include/c.h
src/include/catalog/namespace.h
src/include/commands/dbcommands.h
src/include/commands/tablespace.h
src/include/executor/hashjoin.h
src/include/nodes/bitmapset.h
src/include/nodes/params.h
src/include/nodes/tidbitmap.h
src/include/postgres.h
src/include/postmaster/syslogger.h
src/include/replication/walsender_private.h
src/include/storage/bufpage.h
src/include/storage/fsm_internals.h
src/include/storage/standby.h
src/include/tsearch/dicts/regis.h
src/include/tsearch/dicts/spell.h
src/include/tsearch/ts_type.h
src/include/utils/catcache.h
src/include/utils/datetime.h
src/include/utils/geo_decls.h
src/include/utils/jsonb.h
src/include/utils/relmapper.h
src/include/utils/varbit.h