fundrawtransaction issues after #7518 #7889

issue paveljanik opened this issue on April 16, 2016
  1. paveljanik commented at 8:51 AM on April 16, 2016: contributor

    #7518 introduced new compile warning:

      CXX      wallet/libbitcoin_wallet_a-rpcwallet.o
    wallet/rpcwallet.cpp:2524:71: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
        if (changePosition != -1 && (changePosition < 0 || changePosition > origTx.vout.size()))
                                                           ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~
    1 warning generated.
    

    What if the changePosition is specified as -1, what will happen after this code:

        if (changePosition != -1 && (changePosition < 0 || changePosition > origTx.vout.size()))
            throw JSONRPCError(RPC_INVALID_PARAMETER, "changePosition out of bounds");
    

    ping @promag

  2. paveljanik commented at 8:52 AM on April 16, 2016: contributor

    There is also one in wallet.cpp:

    +wallet/wallet.cpp:2183:50: warning: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [-Wsign-compare]
    +                        else if (nChangePosInOut > txNew.vout.size())
    +                                 ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
    +1 warning generated.
    
  3. ghost commented at 12:19 AM on April 22, 2016: none

    Or the GCC version of it:

    CXX wallet/libbitcoin_wallet_a-rpcwallet.o wallet/rpcwallet.cpp: In function ‘UniValue fundrawtransaction(const UniValue&, bool)’:

    wallet/rpcwallet.cpp:2524:90: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (changePosition != -1 && (changePosition < 0 || changePosition > origTx.vout.size()))

    CXX wallet/libbitcoin_wallet_a-wallet.o wallet/wallet.cpp: In member function ‘bool CWallet::CreateTransaction(const std::vector<CRecipient>&, CWalletTx&, CReserveKey&, CAmount&, int&, std::string&, const CCoinControl*, bool)’:

    wallet/wallet.cpp:2168:68: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] else if (nChangePosInOut > txNew.vout.size())

  4. promag commented at 12:45 AM on April 22, 2016: member

    I don't expect this to ever be a problem. Anyway I can submit a PR to cast one of them. @laanwj WDYT?

  5. laanwj commented at 6:35 AM on April 22, 2016: member

    These warnings are usually annoying at most, but anyone silencing them should take very much care that this doesn't introduce (or rather, obscure) potential overflows.

  6. promag commented at 7:07 AM on April 22, 2016: member

    I'll fix this in #7857 .

  7. MarcoFalke added the label Easy to implement on Apr 22, 2016
  8. MarcoFalke cross-referenced this on Jun 8, 2016 from issue Fix two warnings for comparison between signed and unsigned by sipa
  9. MarcoFalke closed this on Jul 8, 2016

  10. 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