Skip to content

Commit c9eb8d1

Browse files
committed
Merge #13577: logging: avoid nStart may be used uninitialized in AppInitMain warning
2dcd7b4 logging: avoid nStart may be used uninitialized in AppInitMain warning (mruddy) Pull request description: Was getting the following compiler warning: ``` init.cpp: In function ‘bool AppInitMain()’: init.cpp:1616:60: warning: ‘nStart’ may be used uninitialized in this function [-Wmaybe-uninitialized] LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart); ``` It's ok without this PR, but this PR renames `nStart` to `load_block_index_start_time`, makes it `const`, and also reduces the scope of the variable. The logging line is moved such that the the time spent will be logged even if a shutdown is requested while the index is being loaded. Having the log message output even when a shutdown is requested may be how this was intended to work before anyways. That could explain the leading space, as such a log message now looks like: ``` 2018-06-30T11:34:05Z [0%]...[16%]...[33%]...[50%]... block index 25750ms 2018-06-30T11:34:17Z Shutdown requested. Exiting. ``` Tree-SHA512: 967048afbc31f2ce8f80ae7d33fee0bdcbe94550cf2b5b662087e2a7cff14a8bf43d909b30f930660c184ec6c3c7e1302a84e3e54fc1723f7412827f4bf2c518
2 parents 3dc2dcf + 2dcd7b4 commit c9eb8d1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/init.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,8 +1295,6 @@ bool AppInitMain()
12951295
return InitError(_("Unable to start HTTP server. See debug log for details."));
12961296
}
12971297

1298-
int64_t nStart;
1299-
13001298
// ********************************************************* Step 5: verify wallet database integrity
13011299
if (!g_wallet_init_interface.Verify()) return false;
13021300

@@ -1448,8 +1446,8 @@ bool AppInitMain()
14481446

14491447
LOCK(cs_main);
14501448

1451-
nStart = GetTimeMillis();
14521449
do {
1450+
const int64_t load_block_index_start_time = GetTimeMillis();
14531451
try {
14541452
UnloadBlockIndex();
14551453
pcoinsTip.reset();
@@ -1572,6 +1570,7 @@ bool AppInitMain()
15721570
}
15731571

15741572
fLoaded = true;
1573+
LogPrintf(" block index %15dms\n", GetTimeMillis() - load_block_index_start_time);
15751574
} while(false);
15761575

15771576
if (!fLoaded && !ShutdownRequested()) {
@@ -1601,9 +1600,6 @@ bool AppInitMain()
16011600
LogPrintf("Shutdown requested. Exiting.\n");
16021601
return false;
16031602
}
1604-
if (fLoaded) {
1605-
LogPrintf(" block index %15dms\n", GetTimeMillis() - nStart);
1606-
}
16071603

16081604
fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME;
16091605
CAutoFile est_filein(fsbridge::fopen(est_path, "rb"), SER_DISK, CLIENT_VERSION);

0 commit comments

Comments
 (0)