Skip to content

Commit 3c5a33a

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 7d5d3f0 commit 3c5a33a

File tree

7 files changed

+11
-16
lines changed

7 files changed

+11
-16
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/transam/xlog.c

+4
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,9 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic)
21592159
XLogRecPtr NewPageEndPtr = InvalidXLogRecPtr;
21602160
XLogRecPtr NewPageBeginPtr;
21612161
XLogPageHeader NewPage;
2162+
#ifdef WAL_DEBUG
21622163
int npages = 0;
2164+
#endif
21632165

21642166
LWLockAcquire(WALBufMappingLock, LW_EXCLUSIVE);
21652167

@@ -2306,7 +2308,9 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic)
23062308

23072309
XLogCtl->InitializedUpTo = NewPageEndPtr;
23082310

2311+
#ifdef WAL_DEBUG
23092312
npages++;
2313+
#endif
23102314
}
23112315
LWLockRelease(WALBufMappingLock);
23122316

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
@@ -690,6 +690,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
690690
stmtblock: stmtmulti
691691
{
692692
pg_yyget_extra(yyscanner)->parsetree = $1;
693+
(void) yynerrs; /* suppress compiler warning */
693694
}
694695
;
695696

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)