rpc: fix maybe-uninitialized compile warning in getchaintxstats #30544

pull mjdietzx wants to merge 1 commits into bitcoin:master from mjdietzx:202407_fix_getchaintxstats_uninit_var_compiler_warning changing 1 files +4 −6
  1. mjdietzx commented at 5:20 pm on July 29, 2024: contributor

    This resolves the compiler warning about potential uninitialized use of window_tx_count introduced in fa2dada.

    The warning:

    0CXX      rpc/libbitcoin_node_a-blockchain.o
    1rpc/blockchain.cpp: In function getchaintxstats()::<lambda(const RPCHelpMan&, const JSONRPCRequest&)>:
    2rpc/blockchain.cpp:1742:38: warning: *(std::_Optional_payload_base<unsigned int>::_Storage<unsigned int, true>*)((char*)&window_tx_count + offsetof(const std::optional<unsigned int>,std::optional<unsigned int>::<unnamed>.std::_Optional_base<unsigned int, true, true>::<unnamed>)).std::_Optional_payload_base<unsigned int>::_Storage<unsigned int, true>::_M_value may be used uninitialized in this function [-Wmaybe-uninitialized]
    3 1742 |                 ret.pushKV("txrate", double(*window_tx_count) / nTimeDiff);
    4      |
    
  2. rpc: fix maybe-uninitialized compile warning in getchaintxstats
    This resolves the compiler warning about potential uninitialized
    use of window_tx_count introduced in fa2dada.
    2e86f2b201
  3. DrahtBot commented at 5:20 pm on July 29, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK maflcko, theStack, tdb3

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #29656 (chainparams: Change nChainTx type to uint64_t by fjahr)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. DrahtBot added the label RPC/REST/ZMQ on Jul 29, 2024
  5. maflcko commented at 8:05 am on July 30, 2024: member
    lgtm ACK 2e86f2b2019ea0edbd89dd3fd13540c5bbfa104d
  6. theStack approved
  7. theStack commented at 2:33 pm on July 30, 2024: contributor

    ACK 2e86f2b2019ea0edbd89dd3fd13540c5bbfa104d

    Tested with gcc 11.4.0 on Ubuntu 22.04 LTS

    0$ gcc --version | head -n1
    1gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
    
  8. erickcestari approved
  9. tdb3 approved
  10. tdb3 commented at 8:10 pm on August 1, 2024: contributor

    ACK 2e86f2b2019ea0edbd89dd3fd13540c5bbfa104d Nice cleanup.

    Didn’t see the warning with Debian 12.6 and gcc (gcc (Debian 12.2.0-14) 12.2.0) (but did on master). Ran a sanity check of the RPC on signet on the PR branch and master. Both matched.

     0$ src/bitcoin-cli getchaintxstats
     1{
     2  "time": 1722541577,
     3  "txcount": 5441470,
     4  "window_final_block_hash": "000000982e9ac868b72eef37e24695fe965549fd09e253d3e8bf572cfcc636e6",
     5  "window_final_block_height": 206966,
     6  "window_block_count": 4320,
     7  "window_interval": 2573990,
     8  "window_tx_count": 234228,
     9  "txrate": 0.09099802252534003
    10}
    
  11. fanquake merged this on Aug 2, 2024
  12. fanquake closed this on Aug 2, 2024


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-23 09:12 UTC

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