@@ -228,7 +228,6 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
228228 /* Initialize locks and shared memory area */
229229 char * ptr ;
230230 Size offset ;
231- int slotno ;
232231
233232 Assert (!found );
234233
@@ -268,7 +267,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
268267 }
269268
270269 ptr += BUFFERALIGN (offset );
271- for (slotno = 0 ; slotno < nslots ; slotno ++ )
270+ for (int slotno = 0 ; slotno < nslots ; slotno ++ )
272271 {
273272 LWLockInitialize (& shared -> buffer_locks [slotno ].lock ,
274273 tranche_id );
@@ -530,13 +529,12 @@ int
530529SimpleLruReadPage_ReadOnly (SlruCtl ctl , int64 pageno , TransactionId xid )
531530{
532531 SlruShared shared = ctl -> shared ;
533- int slotno ;
534532
535533 /* Try to find the page while holding only shared lock */
536534 LWLockAcquire (shared -> ControlLock , LW_SHARED );
537535
538536 /* See if page is already in a buffer */
539- for (slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
537+ for (int slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
540538 {
541539 if (shared -> page_number [slotno ] == pageno &&
542540 shared -> page_status [slotno ] != SLRU_PAGE_EMPTY &&
@@ -612,9 +610,7 @@ SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
612610 /* If we failed, and we're in a flush, better close the files */
613611 if (!ok && fdata )
614612 {
615- int i ;
616-
617- for (i = 0 ; i < fdata -> num_files ; i ++ )
613+ for (int i = 0 ; i < fdata -> num_files ; i ++ )
618614 CloseTransientFile (fdata -> fd [i ]);
619615 }
620616
@@ -815,12 +811,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
815811 * transaction-commit path).
816812 */
817813 XLogRecPtr max_lsn ;
818- int lsnindex ,
819- lsnoff ;
814+ int lsnindex ;
820815
821816 lsnindex = slotno * shared -> lsn_groups_per_page ;
822817 max_lsn = shared -> group_lsn [lsnindex ++ ];
823- for (lsnoff = 1 ; lsnoff < shared -> lsn_groups_per_page ; lsnoff ++ )
818+ for (int lsnoff = 1 ; lsnoff < shared -> lsn_groups_per_page ; lsnoff ++ )
824819 {
825820 XLogRecPtr this_lsn = shared -> group_lsn [lsnindex ++ ];
826821
@@ -847,9 +842,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
847842 */
848843 if (fdata )
849844 {
850- int i ;
851-
852- for (i = 0 ; i < fdata -> num_files ; i ++ )
845+ for (int i = 0 ; i < fdata -> num_files ; i ++ )
853846 {
854847 if (fdata -> segno [i ] == segno )
855848 {
@@ -1055,7 +1048,6 @@ SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
10551048 /* Outer loop handles restart after I/O */
10561049 for (;;)
10571050 {
1058- int slotno ;
10591051 int cur_count ;
10601052 int bestvalidslot = 0 ; /* keep compiler quiet */
10611053 int best_valid_delta = -1 ;
@@ -1065,7 +1057,7 @@ SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
10651057 int64 best_invalid_page_number = 0 ; /* keep compiler quiet */
10661058
10671059 /* See if page already has a buffer assigned */
1068- for (slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
1060+ for (int slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
10691061 {
10701062 if (shared -> page_number [slotno ] == pageno &&
10711063 shared -> page_status [slotno ] != SLRU_PAGE_EMPTY )
@@ -1100,7 +1092,7 @@ SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
11001092 * multiple pages with the same lru_count.
11011093 */
11021094 cur_count = (shared -> cur_lru_count )++ ;
1103- for (slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
1095+ for (int slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
11041096 {
11051097 int this_delta ;
11061098 int64 this_page_number ;
@@ -1200,9 +1192,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
12001192{
12011193 SlruShared shared = ctl -> shared ;
12021194 SlruWriteAllData fdata ;
1203- int slotno ;
12041195 int64 pageno = 0 ;
1205- int i ;
12061196 bool ok ;
12071197
12081198 /* update the stats counter of flushes */
@@ -1215,7 +1205,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
12151205
12161206 LWLockAcquire (shared -> ControlLock , LW_EXCLUSIVE );
12171207
1218- for (slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
1208+ for (int slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
12191209 {
12201210 SlruInternalWritePage (ctl , slotno , & fdata );
12211211
@@ -1236,7 +1226,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
12361226 * Now close any files that were open
12371227 */
12381228 ok = true;
1239- for (i = 0 ; i < fdata .num_files ; i ++ )
1229+ for (int i = 0 ; i < fdata .num_files ; i ++ )
12401230 {
12411231 if (CloseTransientFile (fdata .fd [i ]) != 0 )
12421232 {
@@ -1372,14 +1362,13 @@ void
13721362SlruDeleteSegment (SlruCtl ctl , int64 segno )
13731363{
13741364 SlruShared shared = ctl -> shared ;
1375- int slotno ;
13761365 bool did_write ;
13771366
13781367 /* Clean out any possibly existing references to the segment. */
13791368 LWLockAcquire (shared -> ControlLock , LW_EXCLUSIVE );
13801369restart :
13811370 did_write = false;
1382- for (slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
1371+ for (int slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
13831372 {
13841373 int pagesegno = shared -> page_number [slotno ] / SLRU_PAGES_PER_SEGMENT ;
13851374
0 commit comments