Skip to content

Commit 612e796

Browse files
committed
Suppress variable-set-but-not-used warnings from clang 15.
clang 15+ will issue a set-but-not-used warning when the only use of a variable is in autoincrements (e.g., "foo++;"). That's perfectly sensible, but it detects a few more cases that we'd not noticed before. Silence the warnings with our usual methods, such as PG_USED_FOR_ASSERTS_ONLY, or in one case by actually removing a useless variable. One thing that we can't nicely get rid of is that with %pure-parser, Bison emits "yynerrs" as a local variable that falls foul of this warning. To silence those, I inserted "(void) yynerrs;" in the top-level productions of affected grammars. Per recently-established 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 to 9.5, which is as far as these patches go without issues. (A preliminary check shows that the prior branches need some other set-but-not-used cleanups too, so I'll leave them for another day.) Discussion: https://postgr.es/m/514615.1663615243@sss.pgh.pa.us
1 parent 9fdeae8 commit 612e796

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

src/backend/access/gist/gistxlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ gistRedoPageUpdateRecord(XLogReaderState *record)
7474
char *begin;
7575
char *data;
7676
Size datalen;
77-
int ninserted = 0;
77+
int ninserted PG_USED_FOR_ASSERTS_ONLY = 0;
7878

7979
data = begin = XLogRecGetBlockData(record, 0, &datalen);
8080

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic)
19051905
XLogRecPtr NewPageEndPtr = InvalidXLogRecPtr;
19061906
XLogRecPtr NewPageBeginPtr;
19071907
XLogPageHeader NewPage;
1908-
int npages = 0;
1908+
int npages pg_attribute_unused() = 0;
19091909

19101910
LWLockAcquire(WALBufMappingLock, LW_EXCLUSIVE);
19111911

src/backend/parser/gram.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
732732
stmtblock: stmtmulti
733733
{
734734
pg_yyget_extra(yyscanner)->parsetree = $1;
735+
(void) yynerrs; /* suppress compiler warning */
735736
}
736737
;
737738

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy