diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index d00097d5501..3a6c43376c5 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -499,7 +499,6 @@ Ledger::rawInsert(std::shared_ptr const& sle) Serializer ss; sle->add(ss); auto item = std::make_shared(sle->key(), std::move(ss)); - // addGiveItem should take ownership if (!stateMap_->addGiveItem(std::move(item), false, false)) LogicError("Ledger::rawInsert: key already exists"); } @@ -510,7 +509,7 @@ Ledger::rawReplace(std::shared_ptr const& sle) Serializer ss; sle->add(ss); auto item = std::make_shared(sle->key(), std::move(ss)); - // updateGiveItem should take ownership + if (!stateMap_->updateGiveItem(std::move(item), false, false)) LogicError("Ledger::rawReplace: key not found"); } diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 3b8a4ad9020..ecff1798bcb 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -591,7 +591,8 @@ class ApplicationImp : public Application, public RootStoppable, public BasicApp , m_loadManager( make_LoadManager(*this, *this, logs_->journal("LoadManager"))) - , txQ_(make_TxQ(setup_TxQ(*config_), logs_->journal("TxQ"))) + , txQ_( + std::make_unique(setup_TxQ(*config_), logs_->journal("TxQ"))) , sweepTimer_(get_io_service()) @@ -1843,8 +1844,8 @@ ApplicationImp::fdRequired() const // Standard handles, config file, misc I/O etc: int needed = 128; - // 1.5 times the configured peer limit for peer connections: - needed += static_cast(0.5 + (1.5 * overlay_->limit())); + // 2x the configured peer limit for peer connections: + needed += 2 * overlay_->limit(); // the number of fds needed by the backend (internally // doubled if online delete is enabled). diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 66c9ab2bb64..cca8266d698 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -81,7 +81,7 @@ class NetworkOPsImp final : public NetworkOPs bool const admin; bool const local; FailHard const failType; - bool applied; + bool applied = false; TER result; TransactionStatus( diff --git a/src/ripple/app/misc/TxQ.h b/src/ripple/app/misc/TxQ.h index 4bdf3e23ee4..64cb544da37 100644 --- a/src/ripple/app/misc/TxQ.h +++ b/src/ripple/app/misc/TxQ.h @@ -774,12 +774,6 @@ class TxQ TxQ::Setup setup_TxQ(Config const&); -/** - @ref TxQ object factory. -*/ -std::unique_ptr -make_TxQ(TxQ::Setup const&, beast::Journal); - template std::pair toDrops(FeeLevel const& level, XRPAmount const& baseFee) diff --git a/src/ripple/app/misc/impl/TxQ.cpp b/src/ripple/app/misc/impl/TxQ.cpp index d2d9fa0bdee..db858a9088d 100644 --- a/src/ripple/app/misc/impl/TxQ.cpp +++ b/src/ripple/app/misc/impl/TxQ.cpp @@ -1549,10 +1549,4 @@ setup_TxQ(Config const& config) return setup; } -std::unique_ptr -make_TxQ(TxQ::Setup const& setup, beast::Journal j) -{ - return std::make_unique(setup, j); -} - } // namespace ripple diff --git a/src/ripple/basics/BasicConfig.h b/src/ripple/basics/BasicConfig.h index 50f576469ba..1b85dee5b2b 100644 --- a/src/ripple/basics/BasicConfig.h +++ b/src/ripple/basics/BasicConfig.h @@ -330,11 +330,10 @@ get(Section const& section, inline std::string get(Section const& section, std::string const& name, const char* defaultValue) { - bool found_and_valid = false; try { auto const val = section.get(name); - if ((found_and_valid = val.is_initialized())) + if (val.is_initialized()) return *val; } catch (boost::bad_lexical_cast&) diff --git a/src/ripple/basics/impl/base64.cpp b/src/ripple/basics/impl/base64.cpp index c80147e3fd7..39b615100e5 100644 --- a/src/ripple/basics/impl/base64.cpp +++ b/src/ripple/basics/impl/base64.cpp @@ -190,7 +190,7 @@ decode(void* dest, char const* src, std::size_t len) { char* out = static_cast(dest); auto in = reinterpret_cast(src); - unsigned char c3[3], c4[4]; + unsigned char c3[3]{}, c4[4]{}; int i = 0; int j = 0; diff --git a/src/ripple/json/impl/json_value.cpp b/src/ripple/json/impl/json_value.cpp index c5659347d4d..aaf8a23b214 100644 --- a/src/ripple/json/impl/json_value.cpp +++ b/src/ripple/json/impl/json_value.cpp @@ -132,7 +132,7 @@ Value::CZString::~CZString() bool Value::CZString::operator<(const CZString& other) const { - if (cstr_) + if (cstr_ && other.cstr_) return strcmp(cstr_, other.cstr_) < 0; return index_ < other.index_; @@ -141,7 +141,7 @@ Value::CZString::operator<(const CZString& other) const bool Value::CZString::operator==(const CZString& other) const { - if (cstr_) + if (cstr_ && other.cstr_) return strcmp(cstr_, other.cstr_) == 0; return index_ == other.index_; diff --git a/src/ripple/protocol/impl/Serializer.cpp b/src/ripple/protocol/impl/Serializer.cpp index 145bf1d3466..03be06b2925 100644 --- a/src/ripple/protocol/impl/Serializer.cpp +++ b/src/ripple/protocol/impl/Serializer.cpp @@ -565,7 +565,7 @@ SerialIter::getFieldID(int& type, int& name) { // uncommon type type = get8(); - if (type == 0 || type < 16) + if (type < 16) Throw( "gFID: uncommon type out of range " + std::to_string(type)); } @@ -574,7 +574,7 @@ SerialIter::getFieldID(int& type, int& name) { // uncommon name name = get8(); - if (name == 0 || name < 16) + if (name < 16) Throw( "gFID: uncommon name out of range " + std::to_string(name)); } diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index bb44388692b..24ffa2f9f99 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -531,7 +531,7 @@ struct ExistingElementPool return STAmount{}; return (*sle)[sfBalance]; }; - std::uint64_t totalXRP[2]; + std::uint64_t totalXRP[2]{}; for (auto ai1 = accounts.begin(), aie = accounts.end(); ai1 != aie; ++ai1) { diff --git a/src/test/nodestore/TestBase.h b/src/test/nodestore/TestBase.h index e35c8d96f30..650d11b515c 100644 --- a/src/test/nodestore/TestBase.h +++ b/src/test/nodestore/TestBase.h @@ -86,23 +86,21 @@ class TestBase : public beast::unit_test::suite for (int i = 0; i < numObjects; ++i) { - NodeObjectType type; - - switch (rand_int(rng, 3)) - { - case 0: - type = hotLEDGER; - break; - case 1: - type = hotACCOUNT_NODE; - break; - case 2: - type = hotTRANSACTION_NODE; - break; - case 3: - type = hotUNKNOWN; - break; - } + NodeObjectType const type = [&] { + switch (rand_int(rng, 3)) + { + case 0: + return hotLEDGER; + case 1: + return hotACCOUNT_NODE; + case 2: + return hotTRANSACTION_NODE; + case 3: + return hotUNKNOWN; + } + // will never happen, but make static analysys tool happy. + return hotUNKNOWN; + }(); uint256 hash; beast::rngfill(hash.begin(), hash.size(), rng);