mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 22:45:52 +00:00
Minor cleanups:
* Make sure variables are always initialized * Use lround instead of adding .5 and casting * Remove some unneeded vars * Check for null before calling strcmp * Remove redundant if conditions * Remove make_TxQ factory function
This commit is contained in:
@@ -499,7 +499,6 @@ Ledger::rawInsert(std::shared_ptr<SLE> const& sle)
|
||||
Serializer ss;
|
||||
sle->add(ss);
|
||||
auto item = std::make_shared<SHAMapItem const>(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<SLE> const& sle)
|
||||
Serializer ss;
|
||||
sle->add(ss);
|
||||
auto item = std::make_shared<SHAMapItem const>(sle->key(), std::move(ss));
|
||||
// updateGiveItem should take ownership
|
||||
|
||||
if (!stateMap_->updateGiveItem(std::move(item), false, false))
|
||||
LogicError("Ledger::rawReplace: key not found");
|
||||
}
|
||||
|
||||
@@ -588,7 +588,8 @@ public:
|
||||
, m_loadManager(
|
||||
make_LoadManager(*this, *this, logs_->journal("LoadManager")))
|
||||
|
||||
, txQ_(make_TxQ(setup_TxQ(*config_), logs_->journal("TxQ")))
|
||||
, txQ_(
|
||||
std::make_unique<TxQ>(setup_TxQ(*config_), logs_->journal("TxQ")))
|
||||
|
||||
, sweepTimer_(get_io_service())
|
||||
|
||||
@@ -1877,8 +1878,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<int>(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).
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -774,12 +774,6 @@ private:
|
||||
TxQ::Setup
|
||||
setup_TxQ(Config const&);
|
||||
|
||||
/**
|
||||
@ref TxQ object factory.
|
||||
*/
|
||||
std::unique_ptr<TxQ>
|
||||
make_TxQ(TxQ::Setup const&, beast::Journal);
|
||||
|
||||
template <class T>
|
||||
std::pair<bool, XRPAmount>
|
||||
toDrops(FeeLevel<T> const& level, XRPAmount const& baseFee)
|
||||
|
||||
@@ -1549,10 +1549,4 @@ setup_TxQ(Config const& config)
|
||||
return setup;
|
||||
}
|
||||
|
||||
std::unique_ptr<TxQ>
|
||||
make_TxQ(TxQ::Setup const& setup, beast::Journal j)
|
||||
{
|
||||
return std::make_unique<TxQ>(setup, j);
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
|
||||
@@ -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<std::string>(name);
|
||||
if ((found_and_valid = val.is_initialized()))
|
||||
if (val.is_initialized())
|
||||
return *val;
|
||||
}
|
||||
catch (boost::bad_lexical_cast&)
|
||||
|
||||
@@ -190,7 +190,7 @@ decode(void* dest, char const* src, std::size_t len)
|
||||
{
|
||||
char* out = static_cast<char*>(dest);
|
||||
auto in = reinterpret_cast<unsigned char const*>(src);
|
||||
unsigned char c3[3], c4[4];
|
||||
unsigned char c3[3]{}, c4[4]{};
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -413,7 +413,7 @@ SerialIter::getFieldID(int& type, int& name)
|
||||
{
|
||||
// uncommon type
|
||||
type = get8();
|
||||
if (type == 0 || type < 16)
|
||||
if (type < 16)
|
||||
Throw<std::runtime_error>(
|
||||
"gFID: uncommon type out of range " + std::to_string(type));
|
||||
}
|
||||
@@ -422,7 +422,7 @@ SerialIter::getFieldID(int& type, int& name)
|
||||
{
|
||||
// uncommon name
|
||||
name = get8();
|
||||
if (name == 0 || name < 16)
|
||||
if (name < 16)
|
||||
Throw<std::runtime_error>(
|
||||
"gFID: uncommon name out of range " + std::to_string(name));
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -86,23 +86,21 @@ public:
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user