Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf38a0bd

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 onlyuse of a variable is in autoincrements (e.g., "foo++;").That's perfectly sensible, but it detects a few more cases thatwe'd not noticed before. Silence the warnings with our usualmethods, such as PG_USED_FOR_ASSERTS_ONLY, or in one case byactually 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 thiswarning. To silence those, I inserted "(void) yynerrs;" in thetop-level productions of affected grammars.Per recently-established project policy, this is a candidatefor back-patching into out-of-support branches: it suppressesannoying compiler warnings but changes no behavior. Hence,back-patch to 9.5, which is as far as these patches go withoutissues. (A preliminary check shows that the prior branchesneed some other set-but-not-used cleanups too, so I'll leavethem for another day.)Discussion:https://postgr.es/m/514615.1663615243@sss.pgh.pa.us
1 parentadc26e0 commitf38a0bd

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

‎src/backend/access/gist/gistxlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ gistRedoPageUpdateRecord(XLogReaderState *record)
8181
char*begin;
8282
char*data;
8383
Sizedatalen;
84-
intninserted=0;
84+
intninsertedPG_USED_FOR_ASSERTS_ONLY=0;
8585

8686
data=begin=XLogRecGetBlockData(record,0,&datalen);
8787

‎src/backend/access/transam/xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic)
21062106
XLogRecPtrNewPageEndPtr=InvalidXLogRecPtr;
21072107
XLogRecPtrNewPageBeginPtr;
21082108
XLogPageHeaderNewPage;
2109-
intnpages=0;
2109+
intnpagespg_attribute_unused()=0;
21102110

21112111
LWLockAcquire(WALBufMappingLock,LW_EXCLUSIVE);
21122112

‎src/backend/parser/gram.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
789789
stmtblock:stmtmulti
790790
{
791791
pg_yyget_extra(yyscanner)->parsetree = $1;
792+
(void)yynerrs;/* suppress compiler warning*/
792793
}
793794
;
794795

‎src/backend/utils/adt/array_typanalyze.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ compute_array_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
218218
{
219219
ArrayAnalyzeExtraData*extra_data;
220220
intnum_mcelem;
221-
intnull_cnt=0;
222221
intnull_elem_cnt=0;
223222
intanalyzed_rows=0;
224223

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

‎src/backend/utils/adt/jsonpath_gram.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ result:
128128
*result = palloc(sizeof(JsonPathParseResult));
129129
(*result)->expr =$2;
130130
(*result)->lax =$1;
131+
(void)yynerrs;
131132
}
132133
|/* EMPTY*/{ *result =NULL; }
133134
;

‎src/bin/pgbench/exprparse.y

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_lis
7979

8080
%%
8181

82-
result:expr{ expr_parse_result =$1; }
82+
result:expr{
83+
expr_parse_result =$1;
84+
(void)yynerrs;/* suppress compiler warning*/
85+
}
8386

8487
elist:{$$ =NULL; }
8588
|expr{$$ = make_elist($1,NULL); }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp