Skip to content

Commit bf21612

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 8c8ee5c commit bf21612

File tree

7 files changed

+7
-19
lines changed

7 files changed

+7
-19
lines changed

contrib/hstore/crc32.c

+2-4
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

+2-4
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

-3
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

-3
Original file line numberDiff line numberDiff line change
@@ -651,16 +651,13 @@ flatten_join_alias_vars_mutator(Node *node,
651651
RowExpr *rowexpr;
652652
List *fields = NIL;
653653
List *colnames = NIL;
654-
AttrNumber attnum;
655654
ListCell *lv;
656655
ListCell *ln;
657656

658-
attnum = 0;
659657
Assert(list_length(rte->joinaliasvars) == list_length(rte->eref->colnames));
660658
forboth(lv, rte->joinaliasvars, ln, rte->eref->colnames)
661659
{
662660
newvar = (Node *) lfirst(lv);
663-
attnum++;
664661
/* Ignore dropped columns */
665662
if (newvar == NULL)
666663
continue;

src/backend/parser/gram.y

+1
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
678678
stmtblock: stmtmulti
679679
{
680680
pg_yyget_extra(yyscanner)->parsetree = $1;
681+
(void) yynerrs; /* suppress compiler warning */
681682
}
682683
;
683684

src/backend/utils/adt/array_typanalyze.c

+1-3
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

+1-2
Original file line numberDiff line numberDiff line change
@@ -3403,7 +3403,6 @@ text_to_array_internal(PG_FUNCTION_ARGS)
34033403
* to search for occurrences of fldsep.
34043404
*/
34053405
TextPositionState state;
3406-
int fldnum;
34073406
int start_posn;
34083407
int end_posn;
34093408
int chunk_len;
@@ -3443,7 +3442,7 @@ text_to_array_internal(PG_FUNCTION_ARGS)
34433442
/* start_ptr points to the start_posn'th character of inputstring */
34443443
start_ptr = VARDATA_ANY(inputstring);
34453444

3446-
for (fldnum = 1;; fldnum++) /* field number is 1 based */
3445+
for (;;)
34473446
{
34483447
CHECK_FOR_INTERRUPTS();
34493448

0 commit comments

Comments
 (0)