@@ -228,7 +228,6 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
228
228
/* Initialize locks and shared memory area */
229
229
char * ptr ;
230
230
Size offset ;
231
- int slotno ;
232
231
233
232
Assert (!found );
234
233
@@ -268,7 +267,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
268
267
}
269
268
270
269
ptr += BUFFERALIGN (offset );
271
- for (slotno = 0 ; slotno < nslots ; slotno ++ )
270
+ for (int slotno = 0 ; slotno < nslots ; slotno ++ )
272
271
{
273
272
LWLockInitialize (& shared -> buffer_locks [slotno ].lock ,
274
273
tranche_id );
@@ -530,13 +529,12 @@ int
530
529
SimpleLruReadPage_ReadOnly (SlruCtl ctl , int64 pageno , TransactionId xid )
531
530
{
532
531
SlruShared shared = ctl -> shared ;
533
- int slotno ;
534
532
535
533
/* Try to find the page while holding only shared lock */
536
534
LWLockAcquire (shared -> ControlLock , LW_SHARED );
537
535
538
536
/* 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 ++ )
540
538
{
541
539
if (shared -> page_number [slotno ] == pageno &&
542
540
shared -> page_status [slotno ] != SLRU_PAGE_EMPTY &&
@@ -612,9 +610,7 @@ SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
612
610
/* If we failed, and we're in a flush, better close the files */
613
611
if (!ok && fdata )
614
612
{
615
- int i ;
616
-
617
- for (i = 0 ; i < fdata -> num_files ; i ++ )
613
+ for (int i = 0 ; i < fdata -> num_files ; i ++ )
618
614
CloseTransientFile (fdata -> fd [i ]);
619
615
}
620
616
@@ -815,12 +811,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
815
811
* transaction-commit path).
816
812
*/
817
813
XLogRecPtr max_lsn ;
818
- int lsnindex ,
819
- lsnoff ;
814
+ int lsnindex ;
820
815
821
816
lsnindex = slotno * shared -> lsn_groups_per_page ;
822
817
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 ++ )
824
819
{
825
820
XLogRecPtr this_lsn = shared -> group_lsn [lsnindex ++ ];
826
821
@@ -847,9 +842,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
847
842
*/
848
843
if (fdata )
849
844
{
850
- int i ;
851
-
852
- for (i = 0 ; i < fdata -> num_files ; i ++ )
845
+ for (int i = 0 ; i < fdata -> num_files ; i ++ )
853
846
{
854
847
if (fdata -> segno [i ] == segno )
855
848
{
@@ -1055,7 +1048,6 @@ SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
1055
1048
/* Outer loop handles restart after I/O */
1056
1049
for (;;)
1057
1050
{
1058
- int slotno ;
1059
1051
int cur_count ;
1060
1052
int bestvalidslot = 0 ; /* keep compiler quiet */
1061
1053
int best_valid_delta = -1 ;
@@ -1065,7 +1057,7 @@ SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
1065
1057
int64 best_invalid_page_number = 0 ; /* keep compiler quiet */
1066
1058
1067
1059
/* 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 ++ )
1069
1061
{
1070
1062
if (shared -> page_number [slotno ] == pageno &&
1071
1063
shared -> page_status [slotno ] != SLRU_PAGE_EMPTY )
@@ -1100,7 +1092,7 @@ SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
1100
1092
* multiple pages with the same lru_count.
1101
1093
*/
1102
1094
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 ++ )
1104
1096
{
1105
1097
int this_delta ;
1106
1098
int64 this_page_number ;
@@ -1200,9 +1192,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
1200
1192
{
1201
1193
SlruShared shared = ctl -> shared ;
1202
1194
SlruWriteAllData fdata ;
1203
- int slotno ;
1204
1195
int64 pageno = 0 ;
1205
- int i ;
1206
1196
bool ok ;
1207
1197
1208
1198
/* update the stats counter of flushes */
@@ -1215,7 +1205,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
1215
1205
1216
1206
LWLockAcquire (shared -> ControlLock , LW_EXCLUSIVE );
1217
1207
1218
- for (slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
1208
+ for (int slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
1219
1209
{
1220
1210
SlruInternalWritePage (ctl , slotno , & fdata );
1221
1211
@@ -1236,7 +1226,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
1236
1226
* Now close any files that were open
1237
1227
*/
1238
1228
ok = true;
1239
- for (i = 0 ; i < fdata .num_files ; i ++ )
1229
+ for (int i = 0 ; i < fdata .num_files ; i ++ )
1240
1230
{
1241
1231
if (CloseTransientFile (fdata .fd [i ]) != 0 )
1242
1232
{
@@ -1372,14 +1362,13 @@ void
1372
1362
SlruDeleteSegment (SlruCtl ctl , int64 segno )
1373
1363
{
1374
1364
SlruShared shared = ctl -> shared ;
1375
- int slotno ;
1376
1365
bool did_write ;
1377
1366
1378
1367
/* Clean out any possibly existing references to the segment. */
1379
1368
LWLockAcquire (shared -> ControlLock , LW_EXCLUSIVE );
1380
1369
restart :
1381
1370
did_write = false;
1382
- for (slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
1371
+ for (int slotno = 0 ; slotno < shared -> num_slots ; slotno ++ )
1383
1372
{
1384
1373
int pagesegno = shared -> page_number [slotno ] / SLRU_PAGES_PER_SEGMENT ;
1385
1374
0 commit comments