Silence compiler warnings on clang 21

Clang 21 shows some new compiler warnings, for example:

warning: variable 'dstsize' is uninitialized when passed as a const pointer argument here [-Wuninitialized-const-pointer]

The fix is to initialize the variables when they are defined.  This is
similar to, for example, the existing situation in gistKeyIsEQ().

Discussion: https://www.postgresql.org/message-id/flat/6604ad6e-5934-43ac-8590-15113d6ae4b1%40eisentraut.org
REL_18_STABLE
Peter Eisentraut 3 days ago
parent 3c02c46521
commit 14bb47567a
  1. 2
      src/backend/access/common/toast_internals.c
  2. 4
      src/backend/access/gist/gistutil.c

@ -135,7 +135,7 @@ toast_save_datum(Relation rel, Datum value,
char data[TOAST_MAX_CHUNK_SIZE + VARHDRSZ];
/* ensure union is aligned well enough: */
int32 align_it;
} chunk_data;
} chunk_data = {0}; /* silence compiler warning */
int32 chunk_size;
int32 chunk_seq = 0;
char *data_p;

@ -157,7 +157,7 @@ gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len,
{
int i;
GistEntryVector *evec;
int attrsize;
int attrsize = 0; /* silence compiler warning */
evec = (GistEntryVector *) palloc((len + 2) * sizeof(GISTENTRY) + GEVHDRSZ);
@ -242,7 +242,7 @@ gistMakeUnionKey(GISTSTATE *giststate, int attno,
char padding[2 * sizeof(GISTENTRY) + GEVHDRSZ];
} storage;
GistEntryVector *evec = &storage.gev;
int dstsize;
int dstsize = 0; /* silence compiler warning */
evec->n = 2;

Loading…
Cancel
Save