[bench] Avoid function call arguments which are pointers to uninitialized values #9949

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:avoid-pointers-to-unitialized-values-in-function-calls changing 1 files +2 −2
  1. practicalswift commented at 11:28 AM on March 8, 2017: contributor

    Prior to this commit:

    bench/checkblock.cpp:41:5: warning: Function call argument is a pointer to uninitialized value [clang-analyzer-core.CallAndMessage]
        stream.write(&a, 1); // Prevent compaction
    
  2. in src/bench/base58.cpp:None in 4c5671f708 outdated
      12 | @@ -13,10 +13,10 @@
      13 |  
      14 |  static void Base58Encode(benchmark::State& state)
      15 |  {
      16 | -    unsigned char buff[32] = {
      17 | +    unsigned char buff[33] = {
    


    laanwj commented at 2:27 PM on March 8, 2017:

    A NUL terminator is unnecessary here, as the array is not interpreted as a string.

  3. [bench] Avoid function call arguments which are pointers to uninitialized values 218d915445
  4. in src/bench/checkblock.cpp:None in 4c5671f708 outdated
      21 | @@ -22,7 +22,7 @@ static void DeserializeBlockTest(benchmark::State& state)
      22 |      CDataStream stream((const char*)block_bench::block413567,
      23 |              (const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
      24 |              SER_NETWORK, PROTOCOL_VERSION);
      25 | -    char a;
      26 | +    char a = '\0';
    


    laanwj commented at 2:28 PM on March 8, 2017:

    ACK on this change

  5. practicalswift force-pushed on Mar 8, 2017
  6. practicalswift commented at 3:41 PM on March 8, 2017: contributor

    @laanwj Thanks for the quick review! This PR is now limited to fixing the two uninitialized values in src/bench/checkblock.cpp.

  7. MarcoFalke commented at 4:02 PM on March 8, 2017: member

    Uninitialized values are fine if they are not read?

  8. TheBlueMatt commented at 9:16 PM on March 8, 2017: member

    @MarcoFalke it looks like these are read, however (well, copied and never acted on, but still technically undefined behavior).

    utACK 218d915445b5936c2de1ffe1e2c97b3f3d20becc

  9. fanquake added the label Tests on Mar 9, 2017
  10. practicalswift commented at 12:18 PM on April 10, 2017: contributor

    Adding link to "Always initialize an object" (ES.20) in the C++ Core Guidelines.

  11. laanwj merged this on Apr 10, 2017
  12. laanwj closed this on Apr 10, 2017

  13. laanwj referenced this in commit a27dbc55b1 on Apr 10, 2017
  14. PastaPastaPasta referenced this in commit 153ea7c31f on May 10, 2019
  15. PastaPastaPasta referenced this in commit e1b5d028fa on May 15, 2019
  16. PastaPastaPasta referenced this in commit e5ecff6e8a on May 20, 2019
  17. PastaPastaPasta referenced this in commit 66990b7dcc on May 21, 2019
  18. markblundeberg referenced this in commit 4a3656974d on Jun 15, 2019
  19. jtoomim referenced this in commit 9594ffa639 on Jun 29, 2019
  20. jonspock referenced this in commit 97a156e747 on Jul 5, 2019
  21. jonspock referenced this in commit 24dec4ef9a on Jul 9, 2019
  22. barrystyle referenced this in commit 834a2bc1af on Jan 22, 2020
  23. practicalswift deleted the branch on Apr 10, 2021
  24. DrahtBot locked this on Aug 16, 2022

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-04-16 15:15 UTC

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