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

Commit421892a

Browse files
committed
Further reduce warnings with -Wshadow=compatible-local
In a similar effort tof01592f, here we're targetting fixing thewarnings that -Wshadow=compatible-local produces that we can fix by movinga variable to an inner scope to stop that variable from being shadowed byanother variable declared somewhere later in the function.All of the warnings being fixed here are changing the scope of variableswhich are being used as an iterator for a "for" loop. In each instance,the fix happens to be changing the for loop to use the C99 typeinitialization. Much of this code likely pre-dates our use of C99.Reducing the scope of the outer scoped variable seems like the safest wayto fix these. Renaming seems more likely to risk patches using the wrongvariable. Reducing the scope is more likely to result in a compilationfailure after applying some future patch rather than introducing bugs withit.By my count, this takes the warning count from 129 down to 114.Author: Justin PryzbyDiscussion:https://postgr.es/m/CAApHDvrwLGBP%2BYw9vriayyf%3DXR4uPWP5jr6cQhP9au_kaDUhbA%40mail.gmail.com
1 parent869e56a commit421892a

File tree

11 files changed

+22
-32
lines changed

11 files changed

+22
-32
lines changed

‎src/backend/access/brin/brin.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
372372
**nullkeys;
373373
int*nkeys,
374374
*nnullkeys;
375-
intkeyno;
376375
char*ptr;
377376
Sizelen;
378377
char*tmpPG_USED_FOR_ASSERTS_ONLY;
@@ -454,7 +453,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
454453
memset(nnullkeys,0,sizeof(int)*bdesc->bd_tupdesc->natts);
455454

456455
/* Preprocess the scan keys - split them into per-attribute arrays. */
457-
for (keyno=0;keyno<scan->numberOfKeys;keyno++)
456+
for (intkeyno=0;keyno<scan->numberOfKeys;keyno++)
458457
{
459458
ScanKeykey=&scan->keyData[keyno];
460459
AttrNumberkeyattno=key->sk_attno;

‎src/backend/access/brin/brin_minmax_multi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ brin_range_serialize(Ranges *range)
582582
inttyplen;
583583
booltypbyval;
584584

585-
inti;
586585
char*ptr;
587586

588587
/* simple sanity checks */
@@ -662,7 +661,7 @@ brin_range_serialize(Ranges *range)
662661
*/
663662
ptr=serialized->data;/* start of the serialized data */
664663

665-
for (i=0;i<nvalues;i++)
664+
for (inti=0;i<nvalues;i++)
666665
{
667666
if (typbyval)/* simple by-value data types */
668667
{

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
234234
Pagepage=BufferGetPage(buffer);
235235
boolis_leaf= (GistPageIsLeaf(page)) ? true : false;
236236
XLogRecPtrrecptr;
237-
inti;
238237
boolis_split;
239238

240239
/*
@@ -420,7 +419,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate,
420419
{
421420
char*data= (char*) (ptr->list);
422421

423-
for (i=0;i<ptr->block.num;i++)
422+
for (inti=0;i<ptr->block.num;i++)
424423
{
425424
IndexTuplethistup= (IndexTuple)data;
426425

‎src/backend/commands/copyfrom.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,6 @@ BeginCopyFrom(ParseState *pstate,
12021202
num_defaults;
12031203
FmgrInfo*in_functions;
12041204
Oid*typioparams;
1205-
intattnum;
12061205
Oidin_func_oid;
12071206
int*defmap;
12081207
ExprState**defexprs;
@@ -1401,7 +1400,7 @@ BeginCopyFrom(ParseState *pstate,
14011400
defmap= (int*)palloc(num_phys_attrs*sizeof(int));
14021401
defexprs= (ExprState**)palloc(num_phys_attrs*sizeof(ExprState*));
14031402

1404-
for (attnum=1;attnum <=num_phys_attrs;attnum++)
1403+
for (intattnum=1;attnum <=num_phys_attrs;attnum++)
14051404
{
14061405
Form_pg_attributeatt=TupleDescAttr(tupDesc,attnum-1);
14071406

‎src/backend/commands/indexcmds.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ DefineIndex(Oid relationId,
565565
Oidroot_save_userid;
566566
introot_save_sec_context;
567567
introot_save_nestlevel;
568-
inti;
569568

570569
root_save_nestlevel=NewGUCNestLevel();
571570

@@ -1047,7 +1046,7 @@ DefineIndex(Oid relationId,
10471046
* We disallow indexes on system columns. They would not necessarily get
10481047
* updated correctly, and they don't seem useful anyway.
10491048
*/
1050-
for (i=0;i<indexInfo->ii_NumIndexAttrs;i++)
1049+
for (inti=0;i<indexInfo->ii_NumIndexAttrs;i++)
10511050
{
10521051
AttrNumberattno=indexInfo->ii_IndexAttrNumbers[i];
10531052

@@ -1067,7 +1066,7 @@ DefineIndex(Oid relationId,
10671066
pull_varattnos((Node*)indexInfo->ii_Expressions,1,&indexattrs);
10681067
pull_varattnos((Node*)indexInfo->ii_Predicate,1,&indexattrs);
10691068

1070-
for (i=FirstLowInvalidHeapAttributeNumber+1;i<0;i++)
1069+
for (inti=FirstLowInvalidHeapAttributeNumber+1;i<0;i++)
10711070
{
10721071
if (bms_is_member(i-FirstLowInvalidHeapAttributeNumber,
10731072
indexattrs))
@@ -1243,7 +1242,7 @@ DefineIndex(Oid relationId,
12431242
* If none matches, build a new index by calling ourselves
12441243
* recursively with the same options (except for the index name).
12451244
*/
1246-
for (i=0;i<nparts;i++)
1245+
for (inti=0;i<nparts;i++)
12471246
{
12481247
OidchildRelid=part_oids[i];
12491248
Relationchildrel;

‎src/backend/executor/nodeAgg.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,13 +1296,12 @@ finalize_aggregates(AggState *aggstate,
12961296
Datum*aggvalues=econtext->ecxt_aggvalues;
12971297
bool*aggnulls=econtext->ecxt_aggnulls;
12981298
intaggno;
1299-
inttransno;
13001299

13011300
/*
13021301
* If there were any DISTINCT and/or ORDER BY aggregates, sort their
13031302
* inputs and run the transition functions.
13041303
*/
1305-
for (transno=0;transno<aggstate->numtrans;transno++)
1304+
for (inttransno=0;transno<aggstate->numtrans;transno++)
13061305
{
13071306
AggStatePerTranspertrans=&aggstate->pertrans[transno];
13081307
AggStatePerGrouppergroupstate;

‎src/backend/optimizer/path/costsize.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,7 +2447,6 @@ append_nonpartial_cost(List *subpaths, int numpaths, int parallel_workers)
24472447
intarrlen;
24482448
ListCell*l;
24492449
ListCell*cell;
2450-
inti;
24512450
intpath_index;
24522451
intmin_index;
24532452
intmax_index;
@@ -2486,7 +2485,6 @@ append_nonpartial_cost(List *subpaths, int numpaths, int parallel_workers)
24862485
for_each_cell(l,subpaths,cell)
24872486
{
24882487
Path*subpath= (Path*)lfirst(l);
2489-
inti;
24902488

24912489
/* Consider only the non-partial paths */
24922490
if (path_index++==numpaths)
@@ -2495,15 +2493,17 @@ append_nonpartial_cost(List *subpaths, int numpaths, int parallel_workers)
24952493
costarr[min_index]+=subpath->total_cost;
24962494

24972495
/* Update the new min cost array index */
2498-
for (min_index=i=0;i<arrlen;i++)
2496+
min_index=0;
2497+
for (inti=0;i<arrlen;i++)
24992498
{
25002499
if (costarr[i]<costarr[min_index])
25012500
min_index=i;
25022501
}
25032502
}
25042503

25052504
/* Return the highest cost from the array */
2506-
for (max_index=i=0;i<arrlen;i++)
2505+
max_index=0;
2506+
for (inti=0;i<arrlen;i++)
25072507
{
25082508
if (costarr[i]>costarr[max_index])
25092509
max_index=i;

‎src/backend/statistics/mcv.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,6 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
16041604
Bitmapset*keys,List*exprs,
16051605
MCVList*mcvlist,boolis_or)
16061606
{
1607-
inti;
16081607
ListCell*l;
16091608
bool*matches;
16101609

@@ -1659,7 +1658,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
16591658
* can skip items that were already ruled out, and terminate if
16601659
* there are no remaining MCV items that might possibly match.
16611660
*/
1662-
for (i=0;i<mcvlist->nitems;i++)
1661+
for (inti=0;i<mcvlist->nitems;i++)
16631662
{
16641663
boolmatch= true;
16651664
MCVItem*item=&mcvlist->items[i];
@@ -1766,7 +1765,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
17661765
* can skip items that were already ruled out, and terminate if
17671766
* there are no remaining MCV items that might possibly match.
17681767
*/
1769-
for (i=0;i<mcvlist->nitems;i++)
1768+
for (inti=0;i<mcvlist->nitems;i++)
17701769
{
17711770
intj;
17721771
boolmatch= !expr->useOr;
@@ -1837,7 +1836,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
18371836
* can skip items that were already ruled out, and terminate if
18381837
* there are no remaining MCV items that might possibly match.
18391838
*/
1840-
for (i=0;i<mcvlist->nitems;i++)
1839+
for (inti=0;i<mcvlist->nitems;i++)
18411840
{
18421841
boolmatch= false;/* assume mismatch */
18431842
MCVItem*item=&mcvlist->items[i];
@@ -1930,7 +1929,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
19301929
* can skip items that were already ruled out, and terminate if
19311930
* there are no remaining MCV items that might possibly match.
19321931
*/
1933-
for (i=0;i<mcvlist->nitems;i++)
1932+
for (inti=0;i<mcvlist->nitems;i++)
19341933
{
19351934
MCVItem*item=&mcvlist->items[i];
19361935
boolmatch= false;
@@ -1956,7 +1955,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
19561955
* can skip items that were already ruled out, and terminate if
19571956
* there are no remaining MCV items that might possibly match.
19581957
*/
1959-
for (i=0;i<mcvlist->nitems;i++)
1958+
for (inti=0;i<mcvlist->nitems;i++)
19601959
{
19611960
boolmatch;
19621961
MCVItem*item=&mcvlist->items[i];

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,7 +3183,6 @@ void
31833183
DropRelationsAllBuffers(SMgrRelation*smgr_reln,intnlocators)
31843184
{
31853185
inti;
3186-
intj;
31873186
intn=0;
31883187
SMgrRelation*rels;
31893188
BlockNumber (*block)[MAX_FORKNUM+1];
@@ -3232,7 +3231,7 @@ DropRelationsAllBuffers(SMgrRelation *smgr_reln, int nlocators)
32323231
*/
32333232
for (i=0;i<n&&cached;i++)
32343233
{
3235-
for (j=0;j <=MAX_FORKNUM;j++)
3234+
for (intj=0;j <=MAX_FORKNUM;j++)
32363235
{
32373236
/* Get the number of blocks for a relation's fork. */
32383237
block[i][j]=smgrnblocks_cached(rels[i],j);
@@ -3259,7 +3258,7 @@ DropRelationsAllBuffers(SMgrRelation *smgr_reln, int nlocators)
32593258
{
32603259
for (i=0;i<n;i++)
32613260
{
3262-
for (j=0;j <=MAX_FORKNUM;j++)
3261+
for (intj=0;j <=MAX_FORKNUM;j++)
32633262
{
32643263
/* ignore relation forks that doesn't exist */
32653264
if (!BlockNumberIsValid(block[i][j]))

‎src/bin/pg_dump/pg_dump.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11576,7 +11576,6 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
1157611576
char **configitems = NULL;
1157711577
intnconfigitems = 0;
1157811578
const char *keyword;
11579-
inti;
1158011579

1158111580
/* Do nothing in data-only dump */
1158211581
if (dopt->dataOnly)
@@ -11853,7 +11852,7 @@ dumpFunc(Archive *fout, const FuncInfo *finfo)
1185311852
finfo->dobj.name);
1185411853
}
1185511854

11856-
for (i = 0; i < nconfigitems; i++)
11855+
for (inti = 0; i < nconfigitems; i++)
1185711856
{
1185811857
/* we feel free to scribble on configitems[] here */
1185911858
char *configitem = configitems[i];

‎src/interfaces/ecpg/pgtypeslib/numeric.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,6 @@ PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result)
10621062
intweight_tmp;
10631063
intrscale_tmp;
10641064
intri;
1065-
inti;
10661065
longguess;
10671066
longfirst_have;
10681067
longfirst_div;
@@ -1109,7 +1108,7 @@ PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result)
11091108
* Initialize local variables
11101109
*/
11111110
init_var(&dividend);
1112-
for (i=1;i<10;i++)
1111+
for (inti=1;i<10;i++)
11131112
init_var(&divisor[i]);
11141113

11151114
/*
@@ -1268,7 +1267,7 @@ PGTYPESnumeric_div(numeric *var1, numeric *var2, numeric *result)
12681267
if (dividend.buf!=NULL)
12691268
digitbuf_free(dividend.buf);
12701269

1271-
for (i=1;i<10;i++)
1270+
for (inti=1;i<10;i++)
12721271
{
12731272
if (divisor[i].buf!=NULL)
12741273
digitbuf_free(divisor[i].buf);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp