Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3e0fff2

Browse files
committed
More -Wshadow=compatible-local warning fixes
In a similar effort to f01592f, here we're targetting fixing the warnings where we've deemed the shadowing variable to serve a close enough purpose to the shadowed variable just to reuse the shadowed version and not declare the shadowing variable at all. By my count, this takes the warning count from 106 down to 71. Author: Justin Pryzby Discussion: https://postgr.es/m/20220825020839.GT2342@telsasoft.com
1 parent e3ce2de commit 3e0fff2

File tree

20 files changed

+8
-51
lines changed

20 files changed

+8
-51
lines changed

src/backend/access/hash/hash_xlog.c

-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ hash_xlog_add_ovfl_page(XLogReaderState *record)
240240
{
241241
Page mappage = (Page) BufferGetPage(mapbuffer);
242242
uint32 *freep = NULL;
243-
char *data;
244243
uint32 *bitmap_page_bit;
245244

246245
freep = HashPageGetBitmap(mappage);

src/backend/access/transam/multixact.c

-1
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,6 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
16141614
if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES)
16151615
{
16161616
dlist_node *node;
1617-
mXactCacheEnt *entry;
16181617

16191618
node = dlist_tail_node(&MXactCache);
16201619
dlist_delete(node);

src/backend/access/transam/xlog.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -3036,8 +3036,7 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli,
30363036
pgstat_report_wait_start(WAIT_EVENT_WAL_INIT_SYNC);
30373037
if (pg_fsync(fd) != 0)
30383038
{
3039-
int save_errno = errno;
3040-
3039+
save_errno = errno;
30413040
close(fd);
30423041
errno = save_errno;
30433042
ereport(ERROR,
@@ -4721,7 +4720,6 @@ XLogInitNewTimeline(TimeLineID endTLI, XLogRecPtr endOfLog, TimeLineID newTLI)
47214720

47224721
if (close(fd) != 0)
47234722
{
4724-
char xlogfname[MAXFNAMELEN];
47254723
int save_errno = errno;
47264724

47274725
XLogFileName(xlogfname, newTLI, startLogSegNo, wal_segment_size);

src/backend/commands/functioncmds.c

-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ compute_return_type(TypeName *returnType, Oid languageOid,
121121
{
122122
char *typnam = TypeNameToString(returnType);
123123
Oid namespaceId;
124-
AclResult aclresult;
125124
char *typname;
126125
ObjectAddress address;
127126

@@ -1112,8 +1111,6 @@ CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
11121111
if (languageStruct->lanpltrusted)
11131112
{
11141113
/* if trusted language, need USAGE privilege */
1115-
AclResult aclresult;
1116-
11171114
aclresult = pg_language_aclcheck(languageOid, GetUserId(), ACL_USAGE);
11181115
if (aclresult != ACLCHECK_OK)
11191116
aclcheck_error(aclresult, OBJECT_LANGUAGE,

src/backend/commands/tablecmds.c

-1
Original file line numberDiff line numberDiff line change
@@ -16796,7 +16796,6 @@ PreCommit_on_commit_actions(void)
1679616796
if (oids_to_drop != NIL)
1679716797
{
1679816798
ObjectAddresses *targetObjects = new_object_addresses();
16799-
ListCell *l;
1680016799

1680116800
foreach(l, oids_to_drop)
1680216801
{

src/backend/commands/vacuum.c

-2
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel)
233233
*/
234234
if (!(params.options & VACOPT_ANALYZE))
235235
{
236-
ListCell *lc;
237-
238236
foreach(lc, vacstmt->rels)
239237
{
240238
VacuumRelation *vrel = lfirst_node(VacuumRelation, lc);

src/backend/executor/execPartition.c

-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
768768
{
769769
List *onconflset;
770770
List *onconflcols;
771-
bool found_whole_row;
772771

773772
/*
774773
* Translate expressions in onConflictSet to account for

src/backend/executor/nodeWindowAgg.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2062,12 +2062,13 @@ ExecWindowAgg(PlanState *pstate)
20622062
if (winstate->all_first)
20632063
{
20642064
int frameOptions = winstate->frameOptions;
2065-
ExprContext *econtext = winstate->ss.ps.ps_ExprContext;
20662065
Datum value;
20672066
bool isnull;
20682067
int16 len;
20692068
bool byval;
20702069

2070+
econtext = winstate->ss.ps.ps_ExprContext;
2071+
20712072
if (frameOptions & FRAMEOPTION_START_OFFSET)
20722073
{
20732074
Assert(winstate->startOffset != NULL);

src/backend/lib/integerset.c

-2
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,6 @@ intset_is_member(IntegerSet *intset, uint64 x)
565565
*/
566566
if (intset->num_buffered_values > 0 && x >= intset->buffered_values[0])
567567
{
568-
int itemno;
569-
570568
itemno = intset_binsrch_uint64(x,
571569
intset->buffered_values,
572570
intset->num_buffered_values,

src/backend/libpq/auth.c

-2
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,6 @@ interpret_ident_response(const char *ident_response,
16521652
return false;
16531653
else
16541654
{
1655-
int i; /* Index into *ident_user */
1656-
16571655
cursor++; /* Go over colon */
16581656
while (pg_isblank(*cursor))
16591657
cursor++; /* skip blanks */

src/backend/optimizer/path/indxpath.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel)
361361
if (bitjoinpaths != NIL)
362362
{
363363
List *all_path_outers;
364-
ListCell *lc;
365364

366365
/* Identify each distinct parameterization seen in bitjoinpaths */
367366
all_path_outers = NIL;
@@ -2188,7 +2187,7 @@ match_clause_to_index(PlannerInfo *root,
21882187
/* Ignore duplicates */
21892188
foreach(lc, clauseset->indexclauses[indexcol])
21902189
{
2191-
IndexClause *iclause = (IndexClause *) lfirst(lc);
2190+
iclause = (IndexClause *) lfirst(lc);
21922191

21932192
if (iclause->rinfo == rinfo)
21942193
return;

src/backend/optimizer/plan/planner.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -3484,8 +3484,6 @@ get_number_of_groups(PlannerInfo *root,
34843484

34853485
if (gd->hash_sets_idx)
34863486
{
3487-
ListCell *lc;
3488-
34893487
gd->dNumHashGroups = 0;
34903488

34913489
groupExprs = get_sortgrouplist_exprs(parse->groupClause,
@@ -4720,8 +4718,6 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
47204718
Path *cheapest_input_path = input_rel->cheapest_total_path;
47214719
double numDistinctRows;
47224720
bool allow_hash;
4723-
Path *path;
4724-
ListCell *lc;
47254721

47264722
/* Estimate number of distinct rows there will be */
47274723
if (parse->groupClause || parse->groupingSets || parse->hasAggs ||
@@ -4766,6 +4762,8 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
47664762
* the other.)
47674763
*/
47684764
List *needed_pathkeys;
4765+
Path *path;
4766+
ListCell *lc;
47694767

47704768
if (parse->hasDistinctOn &&
47714769
list_length(root->distinct_pathkeys) <
@@ -4776,7 +4774,7 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel,
47764774

47774775
foreach(lc, input_rel->pathlist)
47784776
{
4779-
Path *path = (Path *) lfirst(lc);
4777+
path = (Path *) lfirst(lc);
47804778

47814779
if (pathkeys_contained_in(needed_pathkeys, path->pathkeys))
47824780
{
@@ -5034,8 +5032,6 @@ create_ordered_paths(PlannerInfo *root,
50345032
*/
50355033
if (enable_incremental_sort && list_length(root->sort_pathkeys) > 1)
50365034
{
5037-
ListCell *lc;
5038-
50395035
foreach(lc, input_rel->partial_pathlist)
50405036
{
50415037
Path *input_path = (Path *) lfirst(lc);
@@ -7607,7 +7603,6 @@ apply_scanjoin_target_to_paths(PlannerInfo *root,
76077603
AppendRelInfo **appinfos;
76087604
int nappinfos;
76097605
List *child_scanjoin_targets = NIL;
7610-
ListCell *lc;
76117606

76127607
Assert(child_rel != NULL);
76137608

src/backend/optimizer/plan/subselect.c

-10
Original file line numberDiff line numberDiff line change
@@ -2554,8 +2554,6 @@ finalize_plan(PlannerInfo *root, Plan *plan,
25542554

25552555
case T_Append:
25562556
{
2557-
ListCell *l;
2558-
25592557
foreach(l, ((Append *) plan)->appendplans)
25602558
{
25612559
context.paramids =
@@ -2571,8 +2569,6 @@ finalize_plan(PlannerInfo *root, Plan *plan,
25712569

25722570
case T_MergeAppend:
25732571
{
2574-
ListCell *l;
2575-
25762572
foreach(l, ((MergeAppend *) plan)->mergeplans)
25772573
{
25782574
context.paramids =
@@ -2588,8 +2584,6 @@ finalize_plan(PlannerInfo *root, Plan *plan,
25882584

25892585
case T_BitmapAnd:
25902586
{
2591-
ListCell *l;
2592-
25932587
foreach(l, ((BitmapAnd *) plan)->bitmapplans)
25942588
{
25952589
context.paramids =
@@ -2605,8 +2599,6 @@ finalize_plan(PlannerInfo *root, Plan *plan,
26052599

26062600
case T_BitmapOr:
26072601
{
2608-
ListCell *l;
2609-
26102602
foreach(l, ((BitmapOr *) plan)->bitmapplans)
26112603
{
26122604
context.paramids =
@@ -2622,8 +2614,6 @@ finalize_plan(PlannerInfo *root, Plan *plan,
26222614

26232615
case T_NestLoop:
26242616
{
2625-
ListCell *l;
2626-
26272617
finalize_primnode((Node *) ((Join *) plan)->joinqual,
26282618
&context);
26292619
/* collect set of params that will be passed to right child */

src/backend/optimizer/prep/prepunion.c

-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,6 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root,
653653
if (partial_paths_valid)
654654
{
655655
Path *ppath;
656-
ListCell *lc;
657656
int parallel_workers = 0;
658657

659658
/* Find the highest number of workers requested for any subpath. */

src/backend/postmaster/autovacuum.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ rebuild_database_list(Oid newdb)
11021102
*/
11031103
for (i = 0; i < nelems; i++)
11041104
{
1105-
avl_dbase *db = &(dbary[i]);
1105+
db = &(dbary[i]);
11061106

11071107
current_time = TimestampTzPlusMilliseconds(current_time,
11081108
millis_increment);

src/backend/rewrite/rowsecurity.c

-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@ add_with_check_options(Relation rel,
824824
{
825825
RowSecurityPolicy *policy = (RowSecurityPolicy *) lfirst(item);
826826
Expr *qual = QUAL_FOR_WCO(policy);
827-
WithCheckOption *wco;
828827

829828
if (qual != NULL)
830829
{

src/backend/statistics/dependencies.c

-1
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,6 @@ dependency_is_compatible_expression(Node *clause, Index relid, List *statlist, N
12651265
else if (is_orclause(clause))
12661266
{
12671267
BoolExpr *bool_expr = (BoolExpr *) clause;
1268-
ListCell *lc;
12691268

12701269
/* start with no expression (we'll use the first match) */
12711270
*expr = NULL;

src/backend/utils/adt/rangetypes_spgist.c

-2
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,6 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
693693
* quadrants if we're looking for a value strictly greater
694694
* than the maximum.
695695
*/
696-
int cmp;
697696

698697
cmp = range_cmp_bounds(typcache, &centroidLower, maxLower);
699698
if (cmp > 0 || (!inclusive && cmp == 0))
@@ -721,7 +720,6 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
721720
* quadrants if we're looking for a value strictly greater
722721
* than the maximum.
723722
*/
724-
int cmp;
725723

726724
cmp = range_cmp_bounds(typcache, &centroidUpper, maxUpper);
727725
if (cmp > 0 || (!inclusive && cmp == 0))

src/backend/utils/adt/ruleutils.c

-3
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,6 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
13031303
if (!heap_attisnull(ht_idx, Anum_pg_index_indexprs, NULL))
13041304
{
13051305
Datum exprsDatum;
1306-
bool isnull;
13071306
char *exprsString;
13081307

13091308
exprsDatum = SysCacheGetAttr(INDEXRELID, ht_idx,
@@ -1500,7 +1499,6 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
15001499
{
15011500
Node *node;
15021501
Datum predDatum;
1503-
bool isnull;
15041502
char *predString;
15051503

15061504
/* Convert text string to node tree */
@@ -1945,7 +1943,6 @@ pg_get_partkeydef_worker(Oid relid, int prettyFlags,
19451943
if (!heap_attisnull(tuple, Anum_pg_partitioned_table_partexprs, NULL))
19461944
{
19471945
Datum exprsDatum;
1948-
bool isnull;
19491946
char *exprsString;
19501947

19511948
exprsDatum = SysCacheGetAttr(PARTRELID, tuple,

src/bin/pgbench/pgbench.c

-5
Original file line numberDiff line numberDiff line change
@@ -3109,7 +3109,6 @@ sendCommand(CState *st, Command *command)
31093109
for (j = 0; commands[j] != NULL; j++)
31103110
{
31113111
PGresult *res;
3112-
char name[MAX_PREPARE_NAME];
31133112

31143113
if (commands[j]->type != SQL_COMMAND)
31153114
continue;
@@ -3803,8 +3802,6 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg)
38033802
/* quickly skip commands until something to do... */
38043803
while (true)
38053804
{
3806-
Command *command;
3807-
38083805
command = sql_script[st->use_file].commands[st->command];
38093806

38103807
/* cannot reach end of script in that state */
@@ -3959,8 +3956,6 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg)
39593956
*/
39603957
if (report_per_command)
39613958
{
3962-
Command *command;
3963-
39643959
pg_time_now_lazy(&now);
39653960

39663961
command = sql_script[st->use_file].commands[st->command];

0 commit comments

Comments
 (0)