logging: avoid nStart may be used uninitialized in AppInitMain warning #13577

pull mruddy wants to merge 1 commits into bitcoin:master from mruddy:dev1 changing 1 files +2 −6
  1. mruddy commented at 11:45 AM on June 30, 2018: contributor

    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.
    
  2. logging: avoid nStart may be used uninitialized in AppInitMain warning 2dcd7b4ec7
  3. fanquake added the label Refactoring on Jul 1, 2018
  4. Empact cross-referenced this on Jul 1, 2018 from issue Extract AppInitLoadBlockIndex from AppInitMain by Empact
  5. Empact commented at 8:24 PM on July 1, 2018: member

    utACK 2dcd7b4 - I couldn't follow the logic very easily so I did some refactoring in a branch to be sure I understood the cases in #13582

  6. MarcoFalke commented at 9:15 AM on July 2, 2018: member

    utACK 2dcd7b4ec76dc23bf901f4517703758c3fa377ba

  7. laanwj commented at 4:12 PM on July 5, 2018: member

    utACK 2dcd7b4ec76dc23bf901f4517703758c3fa377ba

  8. laanwj merged this on Jul 5, 2018
  9. laanwj closed this on Jul 5, 2018

  10. laanwj referenced this in commit c9eb8d1c55 on Jul 5, 2018
  11. mruddy deleted the branch on Jul 5, 2018
  12. Bushstar cross-referenced this on Jul 9, 2018 from issue commits from bitcoin/master by Bushstar
  13. deadalnix referenced this in commit 8baac1e576 on Jun 18, 2020
  14. PastaPastaPasta referenced this in commit 510d616465 on Jul 9, 2020
  15. PastaPastaPasta referenced this in commit d3a000fb39 on Jul 9, 2020
  16. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC