mirror of
https://github.com/postgres/postgres.git
synced 2025-08-09 17:03:00 +03:00
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.
This commit is contained in:
@@ -424,8 +424,8 @@ typedef struct
|
||||
Oid elemtype;
|
||||
int dim1;
|
||||
int lbound1;
|
||||
int16 values[1]; /* VARIABLE LENGTH ARRAY */
|
||||
} int2vector; /* VARIABLE LENGTH STRUCT */
|
||||
int16 values[FLEXIBLE_ARRAY_MEMBER];
|
||||
} int2vector;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -435,8 +435,8 @@ typedef struct
|
||||
Oid elemtype;
|
||||
int dim1;
|
||||
int lbound1;
|
||||
Oid values[1]; /* VARIABLE LENGTH ARRAY */
|
||||
} oidvector; /* VARIABLE LENGTH STRUCT */
|
||||
Oid values[FLEXIBLE_ARRAY_MEMBER];
|
||||
} oidvector;
|
||||
|
||||
/*
|
||||
* Representation of a Name: effectively just a C string, but null-padded to
|
||||
|
Reference in New Issue
Block a user