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:

    0init.cpp: In function ‘bool AppInitMain()’:
    1init.cpp:1616:60: warning: ‘nStart’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    2         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:

    02018-06-30T11:34:05Z [0%]...[16%]...[33%]...[50%]... block index           25750ms
    12018-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 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
  5. MarcoFalke commented at 9:15 am on July 2, 2018: member
    utACK 2dcd7b4ec76dc23bf901f4517703758c3fa377ba
  6. laanwj commented at 4:12 pm on July 5, 2018: member
    utACK 2dcd7b4ec76dc23bf901f4517703758c3fa377ba
  7. laanwj merged this on Jul 5, 2018
  8. laanwj closed this on Jul 5, 2018

  9. laanwj referenced this in commit c9eb8d1c55 on Jul 5, 2018
  10. mruddy deleted the branch on Jul 5, 2018
  11. deadalnix referenced this in commit 8baac1e576 on Jun 18, 2020
  12. PastaPastaPasta referenced this in commit 510d616465 on Jul 9, 2020
  13. PastaPastaPasta referenced this in commit d3a000fb39 on Jul 9, 2020
  14. DrahtBot 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: 2024-11-17 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me