Skip to content

Commit

Permalink
rpc/server: fix removing deprecated commands from command list
Browse files Browse the repository at this point in the history
The call to std::remove also requires using std::vector::erase

This fixes the following warning:

/home/lukas/Documents/git/Gridcoin-Research/src/rpc/server.cpp:935:20: warning: ignoring return value of ‘_FIter std::remove(_FIter, _FIter, const _Tp&) [with _FIter = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Tp = const char*]’, declared with attribute ‘nodiscard’ [-Wunused-result]
  935 |         std::remove(commandList.begin(), commandList.end(), command);
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /home/lukas/Documents/git/Gridcoin-Research/src/span.h:10,
                 from /home/lukas/Documents/git/Gridcoin-Research/src/uint256.h:10,
                 from /home/lukas/Documents/git/Gridcoin-Research/src/consensus/params.h:9,
                 from /home/lukas/Documents/git/Gridcoin-Research/src/chainparams.h:10,
                 from /home/lukas/Documents/git/Gridcoin-Research/src/main.h:10,
                 from /home/lukas/Documents/git/Gridcoin-Research/src/consensus/tx_verify.h:8,
                 from /home/lukas/Documents/git/Gridcoin-Research/src/wallet/wallet.h:16,
                 from /home/lukas/Documents/git/Gridcoin-Research/src/init.h:9,
                 from /home/lukas/Documents/git/Gridcoin-Research/src/rpc/server.cpp:7:
/usr/include/c++/14/bits/stl_algo.h:788:5: note: declared here
  788 |     remove(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~

Signed-off-by: Lukas Rusak <[email protected]>
  • Loading branch information
lrusak committed Jun 13, 2024
1 parent 2c25758 commit 3bb95c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ std::vector<std::string> CRPCTable::listCommands() const
boost::bind(&commandMap::value_type::first,boost::placeholders::_1) );
// remove deprecated commands from autocomplete
for(auto &command: DEPRECATED_RPCS) {
std::remove(commandList.begin(), commandList.end(), command);
commandList.erase(std::remove(commandList.begin(), commandList.end(), command), commandList.end());
}
return commandList;
}
Expand Down

0 comments on commit 3bb95c2

Please sign in to comment.