Skip to content

Commit 850cb88

Browse files
committed
Suppress more variable-set-but-not-used warnings from clang 15.
Mop up assorted set-but-not-used warnings in the back branches. This includes back-patching relevant fixes from commit 152c9f7 the rest of the way, but there are also several cases that did not appear in HEAD. Some of those we'd fixed in a retail way but not back-patched, and others I think just got rewritten out of existence during nearby refactoring. While here, also back-patch b1980f6 (PL/Tcl: Fix compiler warnings with Tcl 8.6) into 9.2, so that that branch compiles warning-free with modern Tcl. Per project policy, this is a candidate for back-patching into out-of-support branches: it suppresses annoying compiler warnings but changes no behavior. Hence, back-patch all the way to 9.2. Discussion: https://postgr.es/m/514615.1663615243@sss.pgh.pa.us
1 parent 5d3ce0d commit 850cb88

File tree

8 files changed

+14
-21
lines changed

8 files changed

+14
-21
lines changed

contrib/hstore/crc32.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,10 @@ crc32_sz(char *buf, int size)
9595
{
9696
unsigned int crc = ~((unsigned int) 0);
9797
char *p;
98-
int len,
99-
nr;
98+
int nr;
10099

101-
len = 0;
102100
nr = size;
103-
for (len += nr, p = buf; nr--; ++p)
101+
for (p = buf; nr--; ++p)
104102
_CRC32_(crc, *p);
105103
return ~crc;
106104
}

contrib/ltree/crc32.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,10 @@ ltree_crc32_sz(char *buf, int size)
103103
{
104104
unsigned int crc = ~((unsigned int) 0);
105105
char *p;
106-
int len,
107-
nr;
106+
int nr;
108107

109-
len = 0;
110108
nr = size;
111-
for (len += nr, p = buf; nr--; ++p)
109+
for (p = buf; nr--; ++p)
112110
_CRC32_(crc, TOLOWER((unsigned int) *p));
113111
return ~crc;
114112
}

src/backend/access/gin/gindatapage.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
465465
Page rpage = BufferGetPage(rbuf);
466466
Size pageSize = PageGetPageSize(lpage);
467467
Size freeSpace;
468-
uint32 nCopied = 1;
469468

470469
/* these must be static so they can be returned to caller */
471470
static ginxlogSplit data;
@@ -485,15 +484,13 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
485484

486485
if (GinPageIsLeaf(lpage) && GinPageRightMost(lpage) && off > GinPageGetOpaque(lpage)->maxoff)
487486
{
488-
nCopied = 0;
489487
while (btree->curitem < btree->nitem &&
490488
maxoff * sizeof(ItemPointerData) < 2 * (freeSpace - sizeof(ItemPointerData)))
491489
{
492490
memcpy(vector + maxoff * sizeof(ItemPointerData),
493491
btree->items + btree->curitem,
494492
sizeof(ItemPointerData));
495493
maxoff++;
496-
nCopied++;
497494
btree->curitem++;
498495
}
499496
}

src/backend/optimizer/util/var.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,16 +784,13 @@ flatten_join_alias_vars_mutator(Node *node,
784784
RowExpr *rowexpr;
785785
List *fields = NIL;
786786
List *colnames = NIL;
787-
AttrNumber attnum;
788787
ListCell *lv;
789788
ListCell *ln;
790789

791-
attnum = 0;
792790
Assert(list_length(rte->joinaliasvars) == list_length(rte->eref->colnames));
793791
forboth(lv, rte->joinaliasvars, ln, rte->eref->colnames)
794792
{
795793
newvar = (Node *) lfirst(lv);
796-
attnum++;
797794
/* Ignore dropped columns */
798795
if (newvar == NULL)
799796
continue;

src/backend/parser/gram.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ static void processCASbits(int cas_bits, int location, const char *constrType,
653653
stmtblock: stmtmulti
654654
{
655655
pg_yyget_extra(yyscanner)->parsetree = $1;
656+
(void) yynerrs; /* suppress compiler warning */
656657
}
657658
;
658659

src/backend/utils/adt/array_typanalyze.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ compute_array_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
216216
{
217217
ArrayAnalyzeExtraData *extra_data;
218218
int num_mcelem;
219-
int null_cnt = 0;
220219
int null_elem_cnt = 0;
221220
int analyzed_rows = 0;
222221

@@ -321,8 +320,7 @@ compute_array_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
321320
value = fetchfunc(stats, array_no, &isnull);
322321
if (isnull)
323322
{
324-
/* array is null, just count that */
325-
null_cnt++;
323+
/* ignore arrays that are null overall */
326324
continue;
327325
}
328326

src/backend/utils/adt/varlena.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,7 +3169,6 @@ text_to_array_internal(PG_FUNCTION_ARGS)
31693169
* to search for occurrences of fldsep.
31703170
*/
31713171
TextPositionState state;
3172-
int fldnum;
31733172
int start_posn;
31743173
int end_posn;
31753174
int chunk_len;
@@ -3209,7 +3208,7 @@ text_to_array_internal(PG_FUNCTION_ARGS)
32093208
/* start_ptr points to the start_posn'th character of inputstring */
32103209
start_ptr = VARDATA_ANY(inputstring);
32113210

3212-
for (fldnum = 1;; fldnum++) /* field number is 1 based */
3211+
for (;;)
32133212
{
32143213
CHECK_FOR_INTERRUPTS();
32153214

src/pl/tcl/pltcl.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
#define CONST84
1919
#endif
2020

21+
/* ... and for Tcl 8.6. */
22+
#ifndef CONST86
23+
#define CONST86
24+
#endif
25+
2126
#include "access/xact.h"
2227
#include "catalog/pg_proc.h"
2328
#include "catalog/pg_type.h"
@@ -258,7 +263,7 @@ pltcl_FinalizeNotifier(ClientData clientData)
258263
}
259264

260265
static void
261-
pltcl_SetTimer(Tcl_Time *timePtr)
266+
pltcl_SetTimer(CONST86 Tcl_Time *timePtr)
262267
{
263268
}
264269

@@ -284,7 +289,7 @@ pltcl_ServiceModeHook(int mode)
284289
}
285290

286291
static int
287-
pltcl_WaitForEvent(Tcl_Time *timePtr)
292+
pltcl_WaitForEvent(CONST86 Tcl_Time *timePtr)
288293
{
289294
return 0;
290295
}

0 commit comments

Comments
 (0)