chore: Enable clang-tidy misc checks (#6655)

This commit is contained in:
Alex Kremer
2026-03-31 18:29:45 +01:00
committed by Bart
parent 7315c57edc
commit 2dc705bd99
469 changed files with 3915 additions and 3965 deletions

View File

@@ -87,16 +87,19 @@ Checks: "-*,
# cppcoreguidelines-use-default-member-init, # has issues
# cppcoreguidelines-virtual-class-destructor, # has issues
hicpp-ignored-remove-result,
# misc-definitions-in-headers, # has issues
misc-const-correctness,
misc-definitions-in-headers,
misc-header-include-cycle,
misc-misplaced-const,
misc-redundant-expression,
misc-static-assert,
# misc-throw-by-value-catch-by-reference, # has issues
misc-throw-by-value-catch-by-reference,
misc-unused-alias-decls,
misc-unused-using-decls,
modernize-deprecated-headers,
modernize-make-shared,
modernize-make-unique,
llvm-namespace-comment,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
@@ -134,10 +137,7 @@ Checks: "-*,
# ---
# other checks that have issues that need to be resolved:
#
# llvm-namespace-comment,
# misc-const-correctness,
# misc-include-cleaner,
# misc-redundant-expression,
#
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names
# readability-static-accessed-through-instance, # this check is probably unnecessary. it makes the code less readable

View File

@@ -80,7 +80,7 @@ jobs:
env:
TARGETS: ${{ inputs.files != '' && inputs.files || 'src tests' }}
run: |
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" ${TARGETS} 2>&1 | tee clang-tidy-output.txt
run-clang-tidy -j ${{ steps.nproc.outputs.nproc }} -p "${BUILD_DIR}" -quiet -allow-no-checks ${TARGETS} 2>&1 | tee clang-tidy-output.txt
- name: Upload clang-tidy output
if: ${{ github.event.repository.visibility == 'public' && steps.run_clang_tidy.outcome != 'success' }}

View File

@@ -270,14 +270,14 @@ Before running clang-tidy, you must build the project to generate required files
Then run clang-tidy on your local changes:
```
run-clang-tidy -p build src include tests
run-clang-tidy -p build -allow-no-checks src tests
```
This will check all source files in the `src`, `include` and `tests` directories using the compile commands from your `build` directory.
If you wish to automatically fix whatever clang-tidy finds _and_ is capable of fixing, add `-fix` to the above command:
```
run-clang-tidy -p build -fix src include tests
run-clang-tidy -p build -quiet -fix -allow-no-checks src tests
```
## Contracts and instrumentation

View File

@@ -311,7 +311,7 @@ template <class T>
bool
set(T& target, T const& defaultValue, std::string const& name, Section const& section)
{
bool found_and_valid = set<T>(target, name, section);
bool const found_and_valid = set<T>(target, name, section);
if (!found_and_valid)
target = defaultValue;
return found_and_valid;

View File

@@ -448,7 +448,7 @@ inline void
partialDestructorFinished(T** o)
{
T& self = **o;
IntrusiveRefCounts::RefCountPair p =
IntrusiveRefCounts::RefCountPair const p =
self.refCounts.fetch_or(IntrusiveRefCounts::partialDestroyFinishedMask);
XRPL_ASSERT(
(!p.partialDestroyFinishedBit && p.partialDestroyStartedBit && !p.strong),

View File

@@ -94,7 +94,7 @@ class SlabAllocator
std::uint8_t* ret;
{
std::lock_guard l(m_);
std::lock_guard const l(m_);
ret = l_;
@@ -123,7 +123,7 @@ class SlabAllocator
{
XRPL_ASSERT(own(ptr), "xrpl::SlabAllocator::SlabBlock::deallocate : own input");
std::lock_guard l(m_);
std::lock_guard const l(m_);
// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
@@ -210,7 +210,7 @@ public:
// No slab can satisfy our request, so we attempt to allocate a new
// one here:
std::size_t size = slabSize_;
std::size_t const size = slabSize_;
// We want to allocate the memory at a 2 MiB boundary, to make it
// possible to use hugepage mappings on Linux:

View File

@@ -66,12 +66,12 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end)
while (iter != end)
{
int cHigh = digitLookupTable[*iter++];
int const cHigh = digitLookupTable[*iter++];
if (cHigh < 0)
return {};
int cLow = digitLookupTable[*iter++];
int const cLow = digitLookupTable[*iter++];
if (cLow < 0)
return {};

View File

@@ -212,7 +212,7 @@ private:
while (in != sv.end())
{
std::uint32_t accum = {};
for (std::uint32_t shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u})
for (std::uint32_t const shift : {4u, 0u, 12u, 8u, 20u, 16u, 28u, 24u})
{
if (auto const result = hexCharToUInt(*in++, shift, accum);
result != ParseResult::okay)
@@ -444,7 +444,7 @@ public:
for (int i = WIDTH; i--;)
{
std::uint64_t n = carry + boost::endian::big_to_native(data_[i]) +
std::uint64_t const n = carry + boost::endian::big_to_native(data_[i]) +
boost::endian::big_to_native(b.data_[i]);
data_[i] = boost::endian::native_to_big(static_cast<std::uint32_t>(n));

View File

@@ -54,7 +54,7 @@ Throw(Args&&... args)
E e(std::forward<Args>(args)...);
LogThrow(std::string("Throwing exception of type " + beast::type_name<E>() + ": ") + e.what());
throw e;
throw std::move(e);
}
/** Called when faulty logic causes a broken invariant. */

View File

@@ -32,7 +32,7 @@ make_seed_pair() noexcept
// state_t& operator=(state_t const&) = delete;
};
static state_t state;
std::lock_guard lock(state.mutex);
std::lock_guard const lock(state.mutex);
return {state.dist(state.gen), state.dist(state.gen)};
}

View File

@@ -14,11 +14,13 @@ namespace xrpl {
#ifndef __INTELLISENSE__
static_assert(
// NOLINTNEXTLINE(misc-redundant-expression)
std::is_integral<beast::xor_shift_engine::result_type>::value &&
std::is_unsigned<beast::xor_shift_engine::result_type>::value,
"The Ripple default PRNG engine must return an unsigned integral type.");
static_assert(
// NOLINTNEXTLINE(misc-redundant-expression)
std::numeric_limits<beast::xor_shift_engine::result_type>::max() >=
std::numeric_limits<std::uint64_t>::max(),
"The Ripple default PRNG engine return must be at least 64 bits wide.");
@@ -58,7 +60,7 @@ default_prng()
thread_local beast::xor_shift_engine engine = [] {
std::uint64_t seed;
{
std::lock_guard lk(m);
std::lock_guard const lk(m);
std::uniform_int_distribution<std::uint64_t> distribution{1};
seed = distribution(seeder);
}

View File

@@ -83,7 +83,7 @@ public:
void
sample_one(Handler&& handler)
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
if (m_cancel)
throw std::logic_error("io_latency_probe is canceled");
boost::asio::post(
@@ -98,7 +98,7 @@ public:
void
sample(Handler&& handler)
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
if (m_cancel)
throw std::logic_error("io_latency_probe is canceled");
boost::asio::post(
@@ -122,14 +122,14 @@ private:
void
addref()
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
++m_count;
}
void
release()
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
if (--m_count == 0)
m_cond.notify_all();
}
@@ -192,7 +192,7 @@ private:
m_handler(elapsed);
{
std::lock_guard lock(m_probe->m_mutex);
std::lock_guard const lock(m_probe->m_mutex);
if (m_probe->m_cancel)
return;
}

View File

@@ -16,4 +16,4 @@ template <
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_map = detail::aged_ordered_container<false, true, Key, T, Clock, Compare, Allocator>;
}
} // namespace beast

View File

@@ -16,4 +16,4 @@ template <
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_multimap = detail::aged_ordered_container<true, true, Key, T, Clock, Compare, Allocator>;
}
} // namespace beast

View File

@@ -15,4 +15,4 @@ template <
class Allocator = std::allocator<Key>>
using aged_multiset =
detail::aged_ordered_container<true, false, Key, void, Clock, Compare, Allocator>;
}
} // namespace beast

View File

@@ -15,4 +15,4 @@ template <
class Allocator = std::allocator<Key>>
using aged_set = detail::aged_ordered_container<false, false, Key, void, Clock, Compare, Allocator>;
}
} // namespace beast

View File

@@ -17,4 +17,4 @@ template <
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_unordered_map =
detail::aged_unordered_container<false, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
}
} // namespace beast

View File

@@ -17,4 +17,4 @@ template <
class Allocator = std::allocator<std::pair<Key const, T>>>
using aged_unordered_multimap =
detail::aged_unordered_container<true, true, Key, T, Clock, Hash, KeyEqual, Allocator>;
}
} // namespace beast

View File

@@ -17,4 +17,4 @@ template <
using aged_unordered_multiset =
detail::aged_unordered_container<true, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
}
} // namespace beast

View File

@@ -16,4 +16,4 @@ template <
class Allocator = std::allocator<Key>>
using aged_unordered_set =
detail::aged_unordered_container<false, false, Key, void, Clock, Hash, KeyEqual, Allocator>;
}
} // namespace beast

View File

@@ -449,7 +449,7 @@ public:
iterator
erase(iterator pos) noexcept
{
Node* node = &*pos;
Node const* node = &*pos;
++pos;
node->m_next->m_prev = node->m_prev;
node->m_prev->m_next = node->m_next;

View File

@@ -114,7 +114,7 @@ enable_yield_to::spawn(F0&& f, FN&&... fn)
boost::context::fixedsize_stack(2 * 1024 * 1024),
[&](yield_context yield) {
f(yield);
std::lock_guard lock{m_};
std::lock_guard const lock{m_};
if (--running_ == 0)
cv_.notify_all();
},

View File

@@ -228,7 +228,7 @@ template <class>
void
runner::testcase(std::string const& name)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
// Name may not be empty
BOOST_ASSERT(default_ || !name.empty());
// Forgot to call pass or fail
@@ -244,7 +244,7 @@ template <class>
void
runner::pass()
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
if (default_)
testcase("");
on_pass();
@@ -255,7 +255,7 @@ template <class>
void
runner::fail(std::string const& reason)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
if (default_)
testcase("");
on_fail(reason);
@@ -267,7 +267,7 @@ template <class>
void
runner::log(std::string const& s)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
if (default_)
testcase("");
on_log(s);

View File

@@ -300,7 +300,7 @@ private:
static suite**
p_this_suite()
{
static suite* pts = nullptr;
static suite* pts = nullptr; // NOLINT(misc-const-correctness)
return &pts;
}

View File

@@ -28,7 +28,7 @@ struct Zero
namespace {
static constexpr Zero zero{};
}
} // namespace
/** Default implementation of signum calls the method on the class. */
template <typename T>

View File

@@ -56,7 +56,7 @@ private:
// a lock. This removes a small timing window that occurs if the
// waiting thread is handling a spurious wakeup when closureCount_
// drops to zero.
std::lock_guard lock{mutex_};
std::lock_guard const lock{mutex_};
// Update closureCount_. Notify if stopping and closureCount_ == 0.
if ((--closureCount_ == 0) && waitForClosures_)
@@ -168,7 +168,7 @@ public:
{
std::optional<Substitute<Closure>> ret;
std::lock_guard lock{mutex_};
std::lock_guard const lock{mutex_};
if (!waitForClosures_)
ret.emplace(*this, std::forward<Closure>(closure));
@@ -191,7 +191,7 @@ public:
bool
joined() const
{
std::lock_guard lock{mutex_};
std::lock_guard const lock{mutex_};
return waitForClosures_;
}
};

View File

@@ -16,7 +16,7 @@ namespace xrpl {
namespace perf {
class PerfLog;
}
} // namespace perf
class Logs;
struct Coro_create_t

View File

@@ -24,7 +24,7 @@ private:
std::chrono::milliseconds{0})
{
using namespace std::chrono_literals;
int maxLimit = std::numeric_limits<int>::max();
int const maxLimit = std::numeric_limits<int>::max();
auto add = [this](
JobType jt,

View File

@@ -67,7 +67,7 @@ public:
bool
contains(PublicKey const& nodeId)
{
std::lock_guard lock(this->mutex_);
std::lock_guard const lock(this->mutex_);
return table_.find({nodeId}) != table_.end();
}

View File

@@ -14,7 +14,7 @@
namespace beast {
class Journal;
}
} // namespace beast
namespace xrpl {
class Application;

View File

@@ -11,13 +11,13 @@ namespace xrpl {
// Forward declarations
namespace NodeStore {
class Database;
}
} // namespace NodeStore
namespace Resource {
class Manager;
}
} // namespace Resource
namespace perf {
class PerfLog;
}
} // namespace perf
// This is temporary until we migrate all code to use ServiceRegistry.
class Application;

View File

@@ -13,7 +13,7 @@ namespace xrpl {
namespace perf {
class PerfLog;
}
} // namespace perf
/**
* `Workers` is effectively a thread pool. The constructor takes a "callback"

View File

@@ -55,7 +55,7 @@ public:
void
notify()
{
std::lock_guard lock{m_mutex};
std::lock_guard const lock{m_mutex};
++m_count;
m_cond.notify_one();
}

View File

@@ -641,7 +641,7 @@ public:
SelfType
operator++(int)
{
SelfType temp(*this);
SelfType const temp(*this);
++*this;
return temp;
}
@@ -649,7 +649,7 @@ public:
SelfType
operator--(int)
{
SelfType temp(*this);
SelfType const temp(*this);
--*this;
return temp;
}

View File

@@ -143,7 +143,7 @@ public:
// Inject appropriate pseudo-transactions
for (auto const& it : actions)
{
STTx amendTx(ttAMENDMENT, [&it, seq = lastClosedLedger->seq() + 1](auto& obj) {
STTx const amendTx(ttAMENDMENT, [&it, seq = lastClosedLedger->seq() + 1](auto& obj) {
obj.setAccountID(sfAccount, AccountID());
obj.setFieldH256(sfAmendment, it.first);
obj.setFieldU32(sfLedgerSequence, seq);

View File

@@ -6,4 +6,4 @@
namespace xrpl {
using CachedSLEs = TaggedCache<uint256, SLE const>;
}
} // namespace xrpl

View File

@@ -31,7 +31,7 @@ public:
bool
startWork(LedgerIndex seq)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
auto it = map_.find(seq);
@@ -54,7 +54,7 @@ public:
void
finishWork(LedgerIndex seq)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
map_.erase(seq);
await_.notify_all();
@@ -64,7 +64,7 @@ public:
bool
pending(LedgerIndex seq)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
return map_.find(seq) != map_.end();
}
@@ -117,7 +117,7 @@ public:
std::map<LedgerIndex, bool>
getSnapshot() const
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
return map_;
}

View File

@@ -82,6 +82,7 @@ template <class = void>
std::size_t
write_varint(void* p0, std::size_t v)
{
// NOLINTNEXTLINE(misc-const-correctness)
std::uint8_t* p = reinterpret_cast<std::uint8_t*>(p0);
do
{

View File

@@ -102,7 +102,7 @@ template <typename T>
T
toAmount(Issue const& issue, Number const& n, Number::rounding_mode mode = Number::getround())
{
saveNumberRoundMode rm(Number::getround());
saveNumberRoundMode const rm(Number::getround());
if (isXRP(issue))
Number::setround(mode);

View File

@@ -96,7 +96,7 @@ operator<=>(Issue const& lhs, Issue const& rhs)
inline Issue const&
xrpIssue()
{
static Issue issue{xrpCurrency(), xrpAccount()};
static Issue const issue{xrpCurrency(), xrpAccount()};
return issue;
}
@@ -104,7 +104,7 @@ xrpIssue()
inline Issue const&
noIssue()
{
static Issue issue{noCurrency(), noAccount()};
static Issue const issue{noCurrency(), noAccount()};
return issue;
}

View File

@@ -304,8 +304,8 @@ Quality::ceil_TAmounts_helper(
// Use the existing STAmount implementation for now, but consider
// replacing with code specific to IOUAMount and XRPAmount
Amounts stAmt(toSTAmount(amount.in), toSTAmount(amount.out));
STAmount stLim(toSTAmount(limit));
Amounts const stAmt(toSTAmount(amount.in), toSTAmount(amount.out));
STAmount const stLim(toSTAmount(limit));
Amounts const stRes = ((*this).*ceil_function)(stAmt, stLim, roundUp...);
return TAmounts<In, Out>(toAmount<In>(stRes.in), toAmount<Out>(stRes.out));
}

View File

@@ -6,4 +6,4 @@ namespace xrpl {
using LedgerHash = uint256;
}
} // namespace xrpl

View File

@@ -532,7 +532,7 @@ STAmount::fromNumber(A const& a, Number const& number)
{
bool const negative = number.mantissa() < 0;
Number const working{negative ? -number : number};
Asset asset{a};
Asset const asset{a};
if (asset.integral())
{
std::uint64_t const intValue = static_cast<std::int64_t>(working);
@@ -716,7 +716,7 @@ roundToAsset(
std::int32_t scale,
Number::rounding_mode rounding = Number::getround())
{
NumberRoundModeGuard mg(rounding);
NumberRoundModeGuard const mg(rounding);
STAmount const ret{asset, value};
if (ret.integral())
return ret;

View File

@@ -83,7 +83,7 @@ to_json(T const& t)
namespace detail {
class STVar;
}
} // namespace detail
// VFALCO TODO fix this restriction on copy assignment.
//

View File

@@ -8,7 +8,7 @@ namespace xrpl {
class Rules;
namespace test {
class Invariants_test;
}
} // namespace test
class STLedgerEntry final : public STObject, public CountedObject<STLedgerEntry>
{

View File

@@ -1153,7 +1153,7 @@ STObject::getFieldByValue(SField const& field) const
if (!rf)
throwFieldNotFound(field);
SerializedTypeID id = rf->getSType();
SerializedTypeID const id = rf->getSType();
if (id == STI_NOTPRESENT)
return V(); // optional field not present
@@ -1180,7 +1180,7 @@ STObject::getFieldByConstRef(SField const& field, V const& empty) const
if (!rf)
throwFieldNotFound(field);
SerializedTypeID id = rf->getSType();
SerializedTypeID const id = rf->getSType();
if (id == STI_NOTPRESENT)
return empty; // optional field not present

View File

@@ -69,7 +69,7 @@ public:
int
add32(T i)
{
int ret = mData.size();
int const ret = mData.size();
mData.push_back(static_cast<unsigned char>((i >> 24) & 0xff));
mData.push_back(static_cast<unsigned char>((i >> 16) & 0xff));
mData.push_back(static_cast<unsigned char>((i >> 8) & 0xff));
@@ -85,7 +85,7 @@ public:
int
add64(T i)
{
int ret = mData.size();
int const ret = mData.size();
mData.push_back(static_cast<unsigned char>((i >> 56) & 0xff));
mData.push_back(static_cast<unsigned char>((i >> 48) & 0xff));
mData.push_back(static_cast<unsigned char>((i >> 40) & 0xff));
@@ -299,7 +299,7 @@ template <class Iter>
int
Serializer::addVL(Iter begin, Iter end, int len)
{
int ret = addEncoded(len);
int const ret = addEncoded(len);
for (; begin != end; ++begin)
{
addRaw(begin->data(), begin->size());

View File

@@ -4,4 +4,4 @@ namespace xrpl {
enum class TxSearched { All, Some, Unknown };
}
} // namespace xrpl

View File

@@ -15,7 +15,7 @@ enum class TokenCodecErrc {
overflowAdd,
unknown,
};
}
} // namespace xrpl
namespace std {
template <>
@@ -69,7 +69,7 @@ public:
inline xrpl::detail::TokenCodecErrcCategory const&
TokenCodecErrcCategory()
{
static xrpl::detail::TokenCodecErrcCategory c;
static xrpl::detail::TokenCodecErrcCategory const c;
return c;
}

View File

@@ -0,0 +1,3 @@
# This disables all checks for this directory and its subdirectories
Checks: "-*"
InheritParentConfig: false

View File

@@ -14,7 +14,7 @@
namespace soci {
class session;
}
} // namespace soci
namespace xrpl {

View File

@@ -25,7 +25,7 @@
namespace sqlite_api {
struct sqlite3;
}
} // namespace sqlite_api
namespace xrpl {

View File

@@ -93,7 +93,7 @@ public:
Entry* entry(nullptr);
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
auto [resultIt, resultInserted] = table_.emplace(
std::piecewise_construct,
std::make_tuple(kindInbound, address.at_port(0)), // Key
@@ -123,7 +123,7 @@ public:
Entry* entry(nullptr);
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
auto [resultIt, resultInserted] = table_.emplace(
std::piecewise_construct,
std::make_tuple(kindOutbound, address), // Key
@@ -156,7 +156,7 @@ public:
Entry* entry(nullptr);
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
auto [resultIt, resultInserted] = table_.emplace(
std::piecewise_construct,
std::make_tuple(kindUnlimited, address.at_port(1)), // Key
@@ -191,11 +191,11 @@ public:
clock_type::time_point const now(m_clock.now());
Json::Value ret(Json::objectValue);
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
for (auto& inboundEntry : inbound_)
{
int localBalance = inboundEntry.local_balance.value(now);
int const localBalance = inboundEntry.local_balance.value(now);
if ((localBalance + inboundEntry.remote_balance) >= threshold)
{
Json::Value& entry = (ret[inboundEntry.to_string()] = Json::objectValue);
@@ -206,7 +206,7 @@ public:
}
for (auto& outboundEntry : outbound_)
{
int localBalance = outboundEntry.local_balance.value(now);
int const localBalance = outboundEntry.local_balance.value(now);
if ((localBalance + outboundEntry.remote_balance) >= threshold)
{
Json::Value& entry = (ret[outboundEntry.to_string()] = Json::objectValue);
@@ -217,7 +217,7 @@ public:
}
for (auto& adminEntry : admin_)
{
int localBalance = adminEntry.local_balance.value(now);
int const localBalance = adminEntry.local_balance.value(now);
if ((localBalance + adminEntry.remote_balance) >= threshold)
{
Json::Value& entry = (ret[adminEntry.to_string()] = Json::objectValue);
@@ -236,7 +236,7 @@ public:
clock_type::time_point const now(m_clock.now());
Gossip gossip;
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
gossip.items.reserve(inbound_.size());
@@ -261,7 +261,7 @@ public:
{
auto const elapsed = m_clock.now();
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
auto [resultIt, resultInserted] = importTable_.emplace(
std::piecewise_construct,
std::make_tuple(origin), // Key
@@ -318,7 +318,7 @@ public:
void
periodicActivity()
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
auto const elapsed = m_clock.now();
@@ -374,7 +374,7 @@ public:
void
erase(Table::iterator iter)
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
Entry& entry(iter->second);
XRPL_ASSERT(entry.refcount == 0, "xrpl::Resource::Logic::erase : entry not used");
inactive_.erase(inactive_.iterator_to(entry));
@@ -384,14 +384,14 @@ public:
void
acquire(Entry& entry)
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
++entry.refcount;
}
void
release(Entry& entry)
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
if (--entry.refcount == 0)
{
JLOG(m_journal.debug()) << "Inactive " << entry;
@@ -442,7 +442,7 @@ public:
if (!context.empty())
context = " (" + context + ")";
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
clock_type::time_point const now(m_clock.now());
int const balance(entry.add(fee.cost(), now));
JLOG(getStream(fee.cost(), m_journal)) << "Charging " << entry << " for " << fee << context;
@@ -455,7 +455,7 @@ public:
if (entry.isUnlimited())
return false;
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
bool notify(false);
auto const elapsed = m_clock.now();
if (entry.balance(m_clock.now()) >= warningThreshold && elapsed != entry.lastWarningTime)
@@ -478,7 +478,7 @@ public:
if (entry.isUnlimited())
return false;
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
bool drop(false);
clock_type::time_point const now(m_clock.now());
int const balance(entry.balance(now));
@@ -500,7 +500,7 @@ public:
int
balance(Entry& entry)
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
return entry.balance(m_clock.now());
}
@@ -529,7 +529,7 @@ public:
{
clock_type::time_point const now(m_clock.now());
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
{
beast::PropertyStream::Set s("inbound", map);

View File

@@ -39,28 +39,28 @@ public:
setRemoteFee(std::uint32_t f)
{
JLOG(j_.trace()) << "setRemoteFee: " << f;
std::lock_guard sl(lock_);
std::lock_guard const sl(lock_);
remoteTxnLoadFee_ = f;
}
std::uint32_t
getRemoteFee() const
{
std::lock_guard sl(lock_);
std::lock_guard const sl(lock_);
return remoteTxnLoadFee_;
}
std::uint32_t
getLocalFee() const
{
std::lock_guard sl(lock_);
std::lock_guard const sl(lock_);
return localTxnLoadFee_;
}
std::uint32_t
getClusterFee() const
{
std::lock_guard sl(lock_);
std::lock_guard const sl(lock_);
return clusterTxnLoadFee_;
}
@@ -73,14 +73,14 @@ public:
std::uint32_t
getLoadFactor() const
{
std::lock_guard sl(lock_);
std::lock_guard const sl(lock_);
return std::max({clusterTxnLoadFee_, localTxnLoadFee_, remoteTxnLoadFee_});
}
std::pair<std::uint32_t, std::uint32_t>
getScalingFactors() const
{
std::lock_guard sl(lock_);
std::lock_guard const sl(lock_);
return std::make_pair(
std::max(localTxnLoadFee_, remoteTxnLoadFee_),
@@ -91,7 +91,7 @@ public:
setClusterFee(std::uint32_t fee)
{
JLOG(j_.trace()) << "setClusterFee: " << fee;
std::lock_guard sl(lock_);
std::lock_guard const sl(lock_);
clusterTxnLoadFee_ = fee;
}
@@ -103,14 +103,14 @@ public:
bool
isLoadedLocal() const
{
std::lock_guard sl(lock_);
std::lock_guard const sl(lock_);
return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee);
}
bool
isLoadedCluster() const
{
std::lock_guard sl(lock_);
std::lock_guard const sl(lock_);
return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee) ||
(clusterTxnLoadFee_ != lftNormalFee);
}

View File

@@ -401,7 +401,7 @@ public:
void
for_each_manifest(Function&& f) const
{
std::shared_lock lock{mutex_};
std::shared_lock const lock{mutex_};
for (auto const& [_, manifest] : map_)
{
(void)_;
@@ -429,7 +429,7 @@ public:
void
for_each_manifest(PreFun&& pf, EachFun&& f) const
{
std::shared_lock lock{mutex_};
std::shared_lock const lock{mutex_};
pf(map_.size());
for (auto const& [_, manifest] : map_)
{

View File

@@ -19,7 +19,7 @@ namespace boost {
namespace asio {
namespace ssl {
class context;
}
} // namespace ssl
} // namespace asio
} // namespace boost

View File

@@ -300,7 +300,7 @@ BaseHTTPPeer<Handler, Impl>::on_write(error_code const& ec, std::size_t bytes_tr
return fail(ec, "write");
bytes_out_ += bytes_transferred;
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
wq2_.clear();
wq2_.reserve(wq_.size());
std::swap(wq2_, wq_);
@@ -392,7 +392,7 @@ BaseHTTPPeer<Handler, Impl>::write(void const* buf, std::size_t bytes)
if (bytes == 0)
return;
if ([&] {
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
wq_.emplace_back(buf, bytes);
return wq_.size() == 1 && wq2_.size() == 0;
}())
@@ -443,7 +443,7 @@ BaseHTTPPeer<Handler, Impl>::complete()
complete_ = true;
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
if (!wq_.empty() && !wq2_.empty())
return;
}
@@ -476,7 +476,7 @@ BaseHTTPPeer<Handler, Impl>::close(bool graceful)
{
graceful_ = true;
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
if (!wq_.empty() || !wq2_.empty())
return;
}

View File

@@ -418,7 +418,7 @@ BaseWSPeer<Handler, Impl>::on_ping_pong(
{
if (kind == boost::beast::websocket::frame_type::pong)
{
boost::beast::string_view p(payload_.begin());
boost::beast::string_view const p(payload_.begin());
if (payload == p)
{
close_on_timer_ = false;

View File

@@ -165,7 +165,7 @@ io_list::work::destroy()
return;
std::function<void(void)> f;
{
std::lock_guard lock(ios_->m_);
std::lock_guard const lock(ios_->m_);
ios_->map_.erase(this);
if (--ios_->n_ == 0 && ios_->closed_)
{
@@ -195,7 +195,7 @@ io_list::emplace(Args&&... args)
auto sp = std::make_shared<T>(std::forward<Args>(args)...);
decltype(sp) dead;
std::lock_guard lock(m_);
std::lock_guard const lock(m_);
if (!closed_)
{
++n_;

View File

@@ -141,6 +141,7 @@ make_shamapitem(uint256 const& tag, Slice data)
XRPL_ASSERT(
data.size() <= megabytes<std::size_t>(16), "xrpl::make_shamapitem : maximum input size");
// NOLINTNEXTLINE(misc-const-correctness)
std::uint8_t* raw = detail::slabber.allocate(data.size());
// If we can't grab memory from the slab allocators, we fall back to

View File

@@ -9,7 +9,7 @@ namespace xrpl {
namespace path {
namespace detail {
struct FlowDebugInfo;
}
} // namespace detail
} // namespace path
/**

View File

@@ -13,7 +13,7 @@ namespace path {
namespace detail {
struct FlowDebugInfo;
}
} // namespace detail
/** RippleCalc calculates the quality of a payment path.

View File

@@ -571,7 +571,7 @@ flow(
std::size_t const maxTries = 1000;
std::size_t curTry = 0;
std::uint32_t maxOffersToConsider = 1500;
std::uint32_t const maxOffersToConsider = 1500;
std::uint32_t offersConsidered = 0;
// There is a bug in gcc that incorrectly warns about using uninitialized

View File

@@ -22,7 +22,7 @@ reduceOffer(auto const& amount)
static Number const reducedOfferPct(9999, -4);
// Make sure the result is always less than amount or zero.
NumberRoundModeGuard mg(Number::towards_zero);
NumberRoundModeGuard const mg(Number::towards_zero);
return amount * reducedOfferPct;
}
@@ -173,7 +173,7 @@ getAMMOfferStartWithTakerGets(
if (targetQuality.rate() == beast::zero)
return std::nullopt;
NumberRoundModeGuard mg(Number::to_nearest);
NumberRoundModeGuard const mg(Number::to_nearest);
auto const f = feeMult(tfee);
auto const a = 1;
auto const b = pool.in * (1 - 1 / f) / targetQuality.rate() - 2 * pool.out;
@@ -240,7 +240,7 @@ getAMMOfferStartWithTakerPays(
if (targetQuality.rate() == beast::zero)
return std::nullopt;
NumberRoundModeGuard mg(Number::to_nearest);
NumberRoundModeGuard const mg(Number::to_nearest);
auto const f = feeMult(tfee);
auto const& a = f;
auto const b = pool.in * (1 + f);
@@ -435,7 +435,7 @@ swapAssetIn(TAmounts<TIn, TOut> const& pool, TIn const& assetIn, std::uint16_t t
// 1-fee
// maximize:
// fee
saveNumberRoundMode _{Number::getround()};
saveNumberRoundMode const _{Number::getround()};
Number::setround(Number::upward);
auto const numerator = pool.in * pool.out;
@@ -499,7 +499,7 @@ swapAssetOut(TAmounts<TIn, TOut> const& pool, TOut const& assetOut, std::uint16_
// maximize:
// tfee/100000
saveNumberRoundMode _{Number::getround()};
saveNumberRoundMode const _{Number::getround()};
Number::setround(Number::upward);
auto const numerator = pool.in * pool.out;

View File

@@ -20,7 +20,7 @@ extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const&
Throw<std::runtime_error>("Invalid source file");
using archive_ptr = std::unique_ptr<struct archive, void (*)(struct archive*)>;
archive_ptr ar{archive_read_new(), [](struct archive* a) { archive_read_free(a); }};
archive_ptr const ar{archive_read_new(), [](struct archive* a) { archive_read_free(a); }};
if (!ar)
Throw<std::runtime_error>("Failed to allocate archive");
@@ -36,7 +36,8 @@ extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const&
Throw<std::runtime_error>(archive_error_string(ar.get()));
}
archive_ptr aw{archive_write_disk_new(), [](struct archive* a) { archive_write_free(a); }};
archive_ptr const aw{
archive_write_disk_new(), [](struct archive* a) { archive_write_free(a); }};
if (!aw)
Throw<std::runtime_error>("Failed to allocate archive");

View File

@@ -126,7 +126,7 @@ BasicConfig::section(std::string const& name)
Section const&
BasicConfig::section(std::string const& name) const
{
static Section none("");
static Section const none("");
auto const iter = map_.find(name);
if (iter == map_.end())
return none;

View File

@@ -26,7 +26,7 @@ getFileContents(
using namespace boost::filesystem;
using namespace boost::system::errc;
path fullPath{canonical(sourcePath, ec)};
path const fullPath{canonical(sourcePath, ec)};
if (ec)
return {};

View File

@@ -119,7 +119,7 @@ Logs::open(boost::filesystem::path const& pathToLogFile)
beast::Journal::Sink&
Logs::get(std::string const& name)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
auto const result = sinks_.emplace(name, makeSink(name, thresh_));
return *result.first->second;
}
@@ -145,7 +145,7 @@ Logs::threshold() const
void
Logs::threshold(beast::severities::Severity thresh)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
thresh_ = thresh;
for (auto& sink : sinks_)
sink.second->threshold(thresh);
@@ -155,7 +155,7 @@ std::vector<std::pair<std::string, std::string>>
Logs::partition_severities() const
{
std::vector<std::pair<std::string, std::string>> list;
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
list.reserve(sinks_.size());
for (auto const& [name, sink] : sinks_)
list.emplace_back(name, toString(fromSeverity(sink->threshold())));
@@ -171,7 +171,7 @@ Logs::write(
{
std::string s;
format(s, text, level, partition);
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
file_.writeln(s);
if (!silent_)
std::cerr << s << '\n';
@@ -183,7 +183,7 @@ Logs::write(
std::string
Logs::rotate()
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
bool const wasOpened = file_.closeAndReopen();
if (wasOpened)
return "The log file was closed and reopened.";
@@ -411,7 +411,7 @@ public:
std::unique_ptr<beast::Journal::Sink>
set(std::unique_ptr<beast::Journal::Sink> sink)
{
std::lock_guard _(m_);
std::lock_guard const _(m_);
using std::swap;
swap(holder_, sink);
@@ -431,7 +431,7 @@ public:
beast::Journal::Sink&
get()
{
std::lock_guard _(m_);
std::lock_guard const _(m_);
return sink_.get();
}
};

View File

@@ -161,7 +161,7 @@ Number::Guard::push(T d) noexcept
inline unsigned
Number::Guard::pop() noexcept
{
unsigned d = (digits_ & 0xF000'0000'0000'0000) >> 60;
unsigned const d = (digits_ & 0xF000'0000'0000'0000) >> 60;
digits_ <<= 4;
return d;
}
@@ -325,7 +325,7 @@ Number::externalToInternal(rep mantissa)
// int128_t, negate that, and cast it back down to the internalrep
// In practice, this is only going to cover the case of
// std::numeric_limits<rep>::min().
int128_t temp = mantissa;
int128_t const temp = mantissa;
return static_cast<internalrep>(-temp);
}
@@ -530,7 +530,7 @@ Number::operator+=(Number const& y)
uint128_t xm = mantissa_;
auto xe = exponent_;
bool yn = y.negative_;
bool const yn = y.negative_;
uint128_t ym = y.mantissa_;
auto ye = y.exponent_;
Guard g;
@@ -644,14 +644,14 @@ Number::operator*=(Number const& y)
// *m = mantissa
// *e = exponent
bool xn = negative_;
int xs = xn ? -1 : 1;
bool const xn = negative_;
int const xs = xn ? -1 : 1;
internalrep xm = mantissa_;
auto xe = exponent_;
bool yn = y.negative_;
int ys = yn ? -1 : 1;
internalrep ym = y.mantissa_;
bool const yn = y.negative_;
int const ys = yn ? -1 : 1;
internalrep const ym = y.mantissa_;
auto ye = y.exponent_;
auto zm = uint128_t(xm) * uint128_t(ym);
@@ -706,13 +706,13 @@ Number::operator/=(Number const& y)
// *m = mantissa
// *e = exponent
bool np = negative_;
int ns = (np ? -1 : 1);
bool const np = negative_;
int const ns = (np ? -1 : 1);
auto nm = mantissa_;
auto ne = exponent_;
bool dp = y.negative_;
int ds = (dp ? -1 : 1);
bool const dp = y.negative_;
int const ds = (dp ? -1 : 1);
auto dm = y.mantissa_;
auto de = y.exponent_;
@@ -728,7 +728,7 @@ Number::operator/=(Number const& y)
// f can be up to 10^(38-19) = 10^19 safely
static_assert(smallRange.log == 15);
static_assert(largeRange.log == 18);
bool small = Number::getMantissaScale() == MantissaRange::small;
bool const small = Number::getMantissaScale() == MantissaRange::small;
uint128_t const f = small ? 100'000'000'000'000'000 : 10'000'000'000'000'000'000ULL;
XRPL_ASSERT_PARTS(f >= minMantissa * 10, "Number::operator/=", "factor expected size");
@@ -980,8 +980,8 @@ root(Number f, unsigned d)
auto const di = static_cast<int>(d);
auto ex = [e = e, di = di]() // Euclidean remainder of e/d
{
int k = (e >= 0 ? e : e - (di - 1)) / di;
int k2 = e - (k * di);
int const k = (e >= 0 ? e : e - (di - 1)) / di;
int const k2 = e - (k * di);
if (k2 == 0)
return 0;
return di - k2;

View File

@@ -152,7 +152,7 @@ public:
void
asyncHandlersComplete()
{
std::unique_lock<std::mutex> lk{m_mut};
std::unique_lock<std::mutex> const lk{m_mut};
m_asyncHandlersCompleted = true;
m_cv.notify_all();
}
@@ -172,7 +172,7 @@ public:
if (m_stopped.exchange(false))
{
{
std::lock_guard lk{m_mut};
std::lock_guard const lk{m_mut};
m_asyncHandlersCompleted = false;
}
addReference();
@@ -327,7 +327,7 @@ public:
return;
std::string const name(m_work.front().names.back());
HandlerType handler(m_work.front().handler);
HandlerType const handler(m_work.front().handler);
m_work.front().names.pop_back();

View File

@@ -37,7 +37,7 @@ bool
parseUrl(parsedURL& pUrl, std::string const& strUrl)
{
// scheme://username:password@hostname:port/rest
static boost::regex reUrl(
static boost::regex const reUrl(
"(?i)\\`\\s*"
// required scheme
"([[:alpha:]][-+.[:alpha:][:digit:]]*?):"

View File

@@ -103,7 +103,7 @@ std::size_t constexpr decoded_size(std::size_t n)
std::size_t
encode(void* dest, void const* src, std::size_t len)
{
char* out = static_cast<char*>(dest);
char* out = static_cast<char*>(dest); // NOLINT(misc-const-correctness)
char const* in = static_cast<char const*>(src);
auto const tab = base64::get_alphabet();
@@ -154,7 +154,7 @@ encode(void* dest, void const* src, std::size_t len)
std::pair<std::size_t, std::size_t>
decode(void* dest, char const* src, std::size_t len)
{
char* out = static_cast<char*>(dest);
char* out = static_cast<char*>(dest); // NOLINT(misc-const-correctness)
auto in = reinterpret_cast<unsigned char const*>(src);
unsigned char c3[3]{}, c4[4]{};
int i = 0;

View File

@@ -140,7 +140,7 @@ initAnonymous(boost::asio::ssl::context& context)
auto const ts = std::time(nullptr) - (25 * 60 * 60);
int ret = std::strftime(buf, sizeof(buf) - 1, "%y%m%d000000Z", std::gmtime(&ts));
int const ret = std::strftime(buf, sizeof(buf) - 1, "%y%m%d000000Z", std::gmtime(&ts));
buf[ret] = 0;

View File

@@ -41,7 +41,7 @@ seconds_clock_thread::~seconds_clock_thread()
XRPL_ASSERT(
thread_.joinable(), "beast::seconds_clock_thread::~seconds_clock_thread : thread joinable");
{
std::lock_guard lock(mut_);
std::lock_guard const lock(mut_);
stop_ = true;
} // publish stop_ asap so if waiting thread times-out, it will see it
cv_.notify_one();

View File

@@ -62,7 +62,7 @@ chopUInt(int& value, int limit, std::string& input)
return std::isdigit(c, std::locale::classic());
});
std::string item(input.begin(), left_iter);
std::string const item(input.begin(), left_iter);
// Must not be empty
if (item.empty())
@@ -320,7 +320,7 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs)
{
XRPL_ASSERT(!isNumeric(right), "beast::compare : both inputs non-numeric");
int result = left.compare(right);
int const result = left.compare(right);
if (result != 0)
return result;

View File

@@ -4,5 +4,5 @@ namespace beast {
namespace insight {
Collector::~Collector() = default;
}
} // namespace insight
} // namespace beast

View File

@@ -98,7 +98,7 @@ public:
Group::ptr const&
get(std::string const& name) override
{
std::pair<Items::iterator, bool> result(m_items.emplace(name, Group::ptr()));
std::pair<Items::iterator, bool> const result(m_items.emplace(name, Group::ptr()));
Group::ptr& group(result.first->second);
if (result.second)
group = std::make_shared<GroupImp>(name, m_collector);

View File

@@ -5,5 +5,5 @@ namespace beast {
namespace insight {
HookImpl::~HookImpl() = default;
}
} // namespace insight
} // namespace beast

View File

@@ -293,14 +293,14 @@ public:
void
add(StatsDMetricBase& metric)
{
std::lock_guard _(metricsLock_);
std::lock_guard const _(metricsLock_);
metrics_.push_back(metric);
}
void
remove(StatsDMetricBase& metric)
{
std::lock_guard _(metricsLock_);
std::lock_guard const _(metricsLock_);
metrics_.erase(metrics_.iterator_to(metric));
}
@@ -444,7 +444,7 @@ public:
return;
}
std::lock_guard _(metricsLock_);
std::lock_guard const _(metricsLock_);
for (auto& m : metrics_)
m.do_process();

View File

@@ -120,8 +120,7 @@ operator>>(std::istream& is, Endpoint& endpoint)
addrStr += i;
// don't exceed a reasonable length...
if (addrStr.size() == INET6_ADDRSTRLEN ||
((readTo != 0) && readTo == ':' && addrStr.size() > 15))
if (addrStr.size() == INET6_ADDRSTRLEN || (readTo == ':' && addrStr.size() > 15))
{
is.setstate(std::ios_base::failbit);
return is;

View File

@@ -158,7 +158,7 @@ PropertyStream::Source::Source(std::string const& name)
PropertyStream::Source::~Source()
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
if (parent_ != nullptr)
parent_->remove(*this);
removeAll();
@@ -174,8 +174,8 @@ void
PropertyStream::Source::add(Source& source)
{
std::lock(lock_, source.lock_);
std::lock_guard lk1(lock_, std::adopt_lock);
std::lock_guard lk2(source.lock_, std::adopt_lock);
std::lock_guard const lk1(lock_, std::adopt_lock);
std::lock_guard const lk2(source.lock_, std::adopt_lock);
XRPL_ASSERT(
source.parent_ == nullptr, "beast::PropertyStream::Source::add : null source parent");
@@ -187,8 +187,8 @@ void
PropertyStream::Source::remove(Source& child)
{
std::lock(lock_, child.lock_);
std::lock_guard lk1(lock_, std::adopt_lock);
std::lock_guard lk2(child.lock_, std::adopt_lock);
std::lock_guard const lk1(lock_, std::adopt_lock);
std::lock_guard const lk2(child.lock_, std::adopt_lock);
XRPL_ASSERT(
child.parent_ == this, "beast::PropertyStream::Source::remove : child parent match");
@@ -199,10 +199,10 @@ PropertyStream::Source::remove(Source& child)
void
PropertyStream::Source::removeAll()
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
for (auto iter = children_.begin(); iter != children_.end();)
{
std::lock_guard _cl((*iter)->lock_);
std::lock_guard const _cl((*iter)->lock_);
remove(*(*iter));
}
}
@@ -222,7 +222,7 @@ PropertyStream::Source::write(PropertyStream& stream)
Map map(m_name, stream);
onWrite(map);
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
for (auto& child : children_)
child.source().write(stream);
@@ -299,9 +299,9 @@ PropertyStream::Source::peel_name(std::string* path)
if (path->empty())
return "";
std::string::const_iterator first = (*path).begin();
std::string::const_iterator last = (*path).end();
std::string::const_iterator pos = std::find(first, last, '/');
std::string::const_iterator const first = (*path).begin();
std::string::const_iterator const last = (*path).end();
std::string::const_iterator const pos = std::find(first, last, '/');
std::string s(first, pos);
if (pos != last)
@@ -320,11 +320,11 @@ PropertyStream::Source::peel_name(std::string* path)
PropertyStream::Source*
PropertyStream::Source::find_one_deep(std::string const& name)
{
Source* found = find_one(name);
Source* found = find_one(name); // NOLINT(misc-const-correctness)
if (found != nullptr)
return found;
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
for (auto& s : children_)
{
found = s.source().find_one_deep(name);
@@ -355,7 +355,7 @@ PropertyStream::Source::find_path(std::string path)
PropertyStream::Source*
PropertyStream::Source::find_one(std::string const& name)
{
std::lock_guard _(lock_);
std::lock_guard const _(lock_);
for (auto& s : children_)
{
if (s.source().m_name == name)

View File

@@ -22,7 +22,7 @@ HashRouter::emplace(uint256 const& key) -> std::pair<Entry&, bool>
void
HashRouter::addSuppression(uint256 const& key)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
emplace(key);
}
@@ -36,7 +36,7 @@ HashRouter::addSuppressionPeer(uint256 const& key, PeerShortID peer)
std::pair<bool, std::optional<Stopwatch::time_point>>
HashRouter::addSuppressionPeerWithStatus(uint256 const& key, PeerShortID peer)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
auto result = emplace(key);
result.first.addPeer(peer);
@@ -46,7 +46,7 @@ HashRouter::addSuppressionPeerWithStatus(uint256 const& key, PeerShortID peer)
bool
HashRouter::addSuppressionPeer(uint256 const& key, PeerShortID peer, HashRouterFlags& flags)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
auto [s, created] = emplace(key);
s.addPeer(peer);
@@ -61,7 +61,7 @@ HashRouter::shouldProcess(
HashRouterFlags& flags,
std::chrono::seconds tx_interval)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
auto result = emplace(key);
auto& s = result.first;
@@ -73,7 +73,7 @@ HashRouter::shouldProcess(
HashRouterFlags
HashRouter::getFlags(uint256 const& key)
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
return emplace(key).first.getFlags();
}
@@ -83,7 +83,7 @@ HashRouter::setFlags(uint256 const& key, HashRouterFlags flags)
{
XRPL_ASSERT(static_cast<bool>(flags), "xrpl::HashRouter::setFlags : valid input");
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
auto& s = emplace(key).first;
@@ -97,7 +97,7 @@ HashRouter::setFlags(uint256 const& key, HashRouterFlags flags)
auto
HashRouter::shouldRelay(uint256 const& key) -> std::optional<std::set<PeerShortID>>
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
auto& s = emplace(key).first;

View File

@@ -26,7 +26,7 @@ JobQueue::JobQueue(
job_count = m_collector->make_gauge("job_count");
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
for (auto const& x : JobTypes::instance())
{
@@ -52,7 +52,7 @@ JobQueue::~JobQueue()
void
JobQueue::collect()
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
job_count = m_jobSet.size();
}
@@ -78,7 +78,7 @@ JobQueue::addRefCountedJob(JobType type, std::string const& name, JobFunction co
"requires no threads");
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
auto result = m_jobSet.emplace(type, name, ++m_lastJob, data.load(), func);
auto const& job = *result.first;
@@ -106,9 +106,9 @@ JobQueue::addRefCountedJob(JobType type, std::string const& name, JobFunction co
int
JobQueue::getJobCount(JobType t) const
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
JobDataMap::const_iterator c = m_jobData.find(t);
JobDataMap::const_iterator const c = m_jobData.find(t);
return (c == m_jobData.end()) ? 0 : c->second.waiting;
}
@@ -116,9 +116,9 @@ JobQueue::getJobCount(JobType t) const
int
JobQueue::getJobCountTotal(JobType t) const
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
JobDataMap::const_iterator c = m_jobData.find(t);
JobDataMap::const_iterator const c = m_jobData.find(t);
return (c == m_jobData.end()) ? 0 : (c->second.waiting + c->second.running);
}
@@ -129,7 +129,7 @@ JobQueue::getJobCountGE(JobType t) const
// return the number of jobs at this priority level or greater
int ret = 0;
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
for (auto const& x : m_jobData)
{
@@ -143,7 +143,7 @@ JobQueue::getJobCountGE(JobType t) const
std::unique_ptr<LoadEvent>
JobQueue::makeLoadEvent(JobType t, std::string const& name)
{
JobDataMap::iterator iter(m_jobData.find(t));
JobDataMap::iterator const iter(m_jobData.find(t));
XRPL_ASSERT(iter != m_jobData.end(), "xrpl::JobQueue::makeLoadEvent : valid job type input");
if (iter == m_jobData.end())
@@ -158,7 +158,7 @@ JobQueue::addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed)
if (isStopped())
LogicError("JobQueue::addLoadEvents() called after JobQueue stopped");
JobDataMap::iterator iter(m_jobData.find(t));
JobDataMap::iterator const iter(m_jobData.find(t));
XRPL_ASSERT(iter != m_jobData.end(), "xrpl::JobQueue::addLoadEvents : valid job type input");
iter->second.load().addSamples(count, elapsed);
}
@@ -181,7 +181,7 @@ JobQueue::getJson(int c)
Json::Value priorities = Json::arrayValue;
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
for (auto& x : m_jobData)
{
@@ -192,10 +192,10 @@ JobQueue::getJson(int c)
JobTypeData& data(x.second);
LoadMonitor::Stats stats(data.stats());
LoadMonitor::Stats const stats(data.stats());
int waiting(data.waiting);
int running(data.running);
int const waiting(data.waiting);
int const running(data.running);
if ((stats.count != 0) || (waiting != 0) || (stats.latencyPeak != 0ms) || (running != 0))
{
@@ -238,7 +238,7 @@ JobQueue::rendezvous()
JobTypeData&
JobQueue::getJobTypeData(JobType type)
{
JobDataMap::iterator c(m_jobData.find(type));
JobDataMap::iterator const c(m_jobData.find(type));
XRPL_ASSERT(c != m_jobData.end(), "xrpl::JobQueue::getJobTypeData : valid job type input");
// NIKB: This is ugly and I hate it. We must remove jtINVALID completely
@@ -338,12 +338,12 @@ JobQueue::processTask(int instance)
{
Job job;
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
getNextJob(job);
++m_processCount;
}
type = job.getType();
JobTypeData& data(getJobTypeData(type));
JobTypeData const& data(getJobTypeData(type));
JLOG(m_journal.trace()) << "Doing " << data.name() << "job";
// The amount of time that the job was in the queue
@@ -365,7 +365,7 @@ JobQueue::processTask(int instance)
}
{
std::lock_guard lock(m_mutex);
std::lock_guard const lock(m_mutex);
// Job should be destroyed before stopping
// otherwise destructors with side effects can access
// parent objects that are already destroyed.

View File

@@ -104,7 +104,7 @@ LoadMonitor::addLoadSample(LoadEvent const& s)
void
LoadMonitor::addSamples(int count, std::chrono::milliseconds latency)
{
std::lock_guard sl(mutex_);
std::lock_guard const sl(mutex_);
update();
mCounts += count;
@@ -136,7 +136,7 @@ LoadMonitor::isOverTarget(std::chrono::milliseconds avg, std::chrono::millisecon
bool
LoadMonitor::isOver()
{
std::lock_guard sl(mutex_);
std::lock_guard const sl(mutex_);
update();
@@ -153,7 +153,7 @@ LoadMonitor::getStats()
using namespace std::chrono_literals;
Stats stats;
std::lock_guard sl(mutex_);
std::lock_guard const sl(mutex_);
update();

View File

@@ -121,7 +121,7 @@ Workers::deleteWorkers(beast::LockFreeStack<Worker>& stack)
{
for (;;)
{
Worker* const worker = stack.pop_front();
Worker const* const worker = stack.pop_front();
if (worker != nullptr)
{
@@ -150,7 +150,7 @@ Workers::Worker::Worker(Workers& workers, std::string const& threadName, int con
Workers::Worker::~Worker()
{
{
std::lock_guard lock{mutex_};
std::lock_guard const lock{mutex_};
++wakeCount_;
shouldExit_ = true;
}
@@ -162,7 +162,7 @@ Workers::Worker::~Worker()
void
Workers::Worker::notify()
{
std::lock_guard lock{mutex_};
std::lock_guard const lock{mutex_};
++wakeCount_;
wakeup_.notify_one();
}
@@ -178,7 +178,7 @@ Workers::Worker::run()
//
if (++m_workers.m_activeCount == 1)
{
std::lock_guard lk{m_workers.m_mut};
std::lock_guard const lk{m_workers.m_mut};
m_workers.m_allPaused = false;
}
@@ -225,7 +225,7 @@ Workers::Worker::run()
// the predicate evaluation and the actual sleep.
if (--m_workers.m_runningTaskCount == 0)
{
std::lock_guard lk{m_workers.m_mut};
std::lock_guard const lk{m_workers.m_mut};
m_workers.m_cv.notify_all();
}
}
@@ -241,7 +241,7 @@ Workers::Worker::run()
//
if (--m_workers.m_activeCount == 0)
{
std::lock_guard lk{m_workers.m_mut};
std::lock_guard const lk{m_workers.m_mut};
m_workers.m_allPaused = true;
m_workers.m_cv.notify_all();
}

View File

@@ -312,8 +312,8 @@ RFC1751::wsrch(std::string const& strWord, int iMin, int iMax)
while (iResult < 0 && iMin != iMax)
{
// Have a range to search.
int iMid = iMin + ((iMax - iMin) / 2);
int iDir = strWord.compare(s_dictionary[iMid]);
int const iMid = iMin + ((iMax - iMin) / 2);
int const iDir = strWord.compare(s_dictionary[iMid]);
if (iDir == 0)
{
@@ -349,7 +349,7 @@ RFC1751::etob(std::string& strData, std::vector<std::string> vsHuman)
for (auto& strWord : vsHuman)
{
int l = strWord.length();
int const l = strWord.length();
if (l > 4 || l < 1)
return -1;

View File

@@ -42,7 +42,7 @@ csprng_engine::mix_entropy(void* buffer, std::size_t count)
e = rd();
}
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
// We add data to the pool, but we conservatively assume that
// it contributes no actual entropy.

View File

@@ -80,7 +80,7 @@ public:
void
start(CollectionType ct)
{
char ch = (ct == array) ? openBracket : openBrace;
char const ch = (ct == array) ? openBracket : openBrace;
output({&ch, 1});
stack_.push(Collection());
stack_.top().type = ct;

View File

@@ -93,7 +93,7 @@ Reader::parse(char const* beginDoc, char const* endDoc, Value& root)
nodes_.pop();
nodes_.push(&root);
bool successful = readValue(0);
bool const successful = readValue(0);
Token token{};
skipCommentTokens(token);
@@ -186,7 +186,7 @@ Reader::readToken(Token& token)
{
skipSpaces();
token.start_ = current_;
Char c = getNextChar();
Char const c = getNextChar();
bool ok = true;
switch (c)
@@ -275,7 +275,7 @@ Reader::skipSpaces()
{
while (current_ != end_)
{
Char c = *current_;
Char const c = *current_;
if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
{
@@ -309,7 +309,7 @@ Reader::match(Location pattern, int patternLength)
bool
Reader::readComment()
{
Char c = getNextChar();
Char const c = getNextChar();
if (c == '*')
return readCStyleComment();
@@ -325,7 +325,7 @@ Reader::readCStyleComment()
{
while (current_ != end_)
{
Char c = getNextChar();
Char const c = getNextChar();
if (c == '*' && *current_ == '/')
break;
@@ -339,7 +339,7 @@ Reader::readCppStyleComment()
{
while (current_ != end_)
{
Char c = getNextChar();
Char const c = getNextChar();
if (c == '\r' || c == '\n')
break;
@@ -444,7 +444,7 @@ Reader::readObject(Token& tokenStart, unsigned depth)
Value& value = currentValue()[name];
nodes_.push(&value);
bool ok = readValue(depth + 1);
bool const ok = readValue(depth + 1);
nodes_.pop();
if (!ok) // error already set
@@ -506,7 +506,8 @@ Reader::readArray(Token& tokenStart, unsigned depth)
ok = readToken(token);
}
bool badTokenType = (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
bool const badTokenType =
(token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
if (!ok || badTokenType)
{
@@ -525,7 +526,7 @@ bool
Reader::decodeNumber(Token& token)
{
Location current = token.start_;
bool isNegative = *current == '-';
bool const isNegative = *current == '-';
if (isNegative)
++current;
@@ -546,7 +547,7 @@ Reader::decodeNumber(Token& token)
while (current < token.end_ && (value <= Value::maxUInt))
{
Char c = *current++;
Char const c = *current++;
if (c < '0' || c > '9')
{
@@ -606,7 +607,7 @@ Reader::decodeDouble(Token& token)
double value = 0;
int const bufferSize = 32;
int count = 0;
int length = int(token.end_ - token.start_);
int const length = int(token.end_ - token.start_);
// Sanity check to avoid buffer overflow exploits.
if (length < 0)
{
@@ -627,7 +628,7 @@ Reader::decodeDouble(Token& token)
}
else
{
std::string buffer(token.start_, token.end_);
std::string const buffer(token.start_, token.end_);
count = sscanf(buffer.c_str(), format, &value);
}
if (count != 1)
@@ -657,7 +658,7 @@ Reader::decodeString(Token& token, std::string& decoded)
while (current != end)
{
Char c = *current++;
Char const c = *current++;
if (c == '"')
{
@@ -668,7 +669,7 @@ Reader::decodeString(Token& token, std::string& decoded)
if (current == end)
return addError("Empty escape sequence in string", token, current);
Char escape = *current++;
Char const escape = *current++;
switch (escape)
{
@@ -783,7 +784,7 @@ Reader::decodeUnicodeEscapeSequence(
for (int index = 0; index < 4; ++index)
{
Char c = *current++;
Char const c = *current++;
unicode *= 16;
if (c >= '0' && c <= '9')
@@ -825,7 +826,7 @@ Reader::addError(std::string const& message, Token& token, Location extra)
bool
Reader::recoverFromError(TokenType skipUntilToken)
{
int errorCount = int(errors_.size());
int const errorCount = int(errors_.size());
Token skip{};
while (true)
@@ -872,7 +873,7 @@ Reader::getLocationLineAndColumn(Location location, int& line, int& column) cons
while (current < location && current != end_)
{
Char c = *current++;
Char const c = *current++;
if (c == '\r')
{
@@ -924,7 +925,7 @@ std::istream&
operator>>(std::istream& sin, Value& root)
{
Json::Reader reader;
bool ok = reader.parse(sin, root);
bool const ok = reader.parse(sin, root);
// XRPL_ASSERT(ok, "Json::operator>>() : parse succeeded");
if (!ok)

View File

@@ -60,6 +60,7 @@ public:
static ValueAllocator*&
valueAllocator()
{
// NOLINTNEXTLINE(misc-const-correctness)
static ValueAllocator* valueAllocator = new DefaultValueAllocator;
return valueAllocator;
}
@@ -333,11 +334,11 @@ Value::swap(Value& other) noexcept
{
std::swap(value_, other.value_);
ValueType temp = type_;
ValueType const temp = type_;
type_ = other.type_;
other.type_ = temp;
int temp2 = allocated_;
int const temp2 = allocated_;
allocated_ = other.allocated_;
other.allocated_ = temp2;
}
@@ -401,7 +402,7 @@ operator<(Value const& x, Value const& y)
case arrayValue:
case objectValue: {
if (int signum = int(x.value_.map_->size()) - y.value_.map_->size())
if (int const signum = int(x.value_.map_->size()) - y.value_.map_->size())
return signum < 0;
return *x.value_.map_ < *y.value_.map_;
@@ -848,13 +849,13 @@ Value::operator[](UInt index)
if (type_ == nullValue)
*this = Value(arrayValue);
CZString key(index);
CZString const key(index);
ObjectValues::iterator it = value_.map_->lower_bound(key);
if (it != value_.map_->end() && (*it).first == key)
return (*it).second;
ObjectValues::value_type defaultValue(key, null);
ObjectValues::value_type const defaultValue(key, null);
it = value_.map_->insert(it, defaultValue);
return (*it).second;
}
@@ -869,8 +870,8 @@ Value::operator[](UInt index) const
if (type_ == nullValue)
return null;
CZString key(index);
ObjectValues::const_iterator it = value_.map_->find(key);
CZString const key(index);
ObjectValues::const_iterator const it = value_.map_->find(key);
if (it == value_.map_->end())
return null;
@@ -893,13 +894,13 @@ Value::resolveReference(char const* key, bool isStatic)
if (type_ == nullValue)
*this = Value(objectValue);
CZString actualKey(key, isStatic ? CZString::noDuplication : CZString::duplicateOnCopy);
CZString const actualKey(key, isStatic ? CZString::noDuplication : CZString::duplicateOnCopy);
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
if (it != value_.map_->end() && (*it).first == actualKey)
return (*it).second;
ObjectValues::value_type defaultValue(actualKey, null);
ObjectValues::value_type const defaultValue(actualKey, null);
it = value_.map_->insert(it, defaultValue);
Value& value = (*it).second;
return value;
@@ -928,8 +929,8 @@ Value::operator[](char const* key) const
if (type_ == nullValue)
return null;
CZString actualKey(key, CZString::noDuplication);
ObjectValues::const_iterator it = value_.map_->find(actualKey);
CZString const actualKey(key, CZString::noDuplication);
ObjectValues::const_iterator const it = value_.map_->find(actualKey);
if (it == value_.map_->end())
return null;
@@ -995,8 +996,8 @@ Value::removeMember(char const* key)
if (type_ == nullValue)
return null;
CZString actualKey(key, CZString::noDuplication);
ObjectValues::iterator it = value_.map_->find(actualKey);
CZString const actualKey(key, CZString::noDuplication);
ObjectValues::iterator const it = value_.map_->find(actualKey);
if (it == value_.map_->end())
return null;
@@ -1046,7 +1047,7 @@ Value::getMemberNames() const
Members members;
members.reserve(value_.map_->size());
ObjectValues::const_iterator it = value_.map_->begin();
ObjectValues::const_iterator itEnd = value_.map_->end();
ObjectValues::const_iterator const itEnd = value_.map_->end();
for (; it != itEnd; ++it)
members.push_back(std::string((*it).first.c_str()));

View File

@@ -47,8 +47,8 @@ std::string
valueToString(Int value)
{
char buffer[32];
char* current = buffer + sizeof(buffer);
bool isNegative = value < 0;
char* current = buffer + sizeof(buffer); // NOLINT(misc-const-correctness)
bool const isNegative = value < 0;
if (isNegative)
value = -value;
@@ -66,7 +66,7 @@ std::string
valueToString(UInt value)
{
char buffer[32];
char* current = buffer + sizeof(buffer);
char* current = buffer + sizeof(buffer); // NOLINT(misc-const-correctness)
uintToString(value, current);
XRPL_ASSERT(current >= buffer, "Json::valueToString(UInt) : buffer check");
return current;
@@ -106,7 +106,7 @@ valueToQuotedString(char const* value)
// We have to walk value and escape any special characters.
// Appending to std::string is not efficient, but this should be rare.
// (Note: forward slashes are *not* rare, but I am not escaping them.)
unsigned maxsize = (strlen(value) * 2) + 3; // all-escaped+quotes+NULL
unsigned const maxsize = (strlen(value) * 2) + 3; // all-escaped+quotes+NULL
std::string result;
result.reserve(maxsize); // to avoid lots of mallocs
result += "\"";
@@ -213,7 +213,7 @@ FastWriter::writeValue(Value const& value)
case arrayValue: {
document_ += "[";
int size = value.size();
int const size = value.size();
for (int index = 0; index < size; ++index)
{
@@ -338,7 +338,7 @@ StyledWriter::writeValue(Value const& value)
void
StyledWriter::writeArrayValue(Value const& value)
{
unsigned size = value.size();
unsigned const size = value.size();
if (size == 0)
{
@@ -346,13 +346,13 @@ StyledWriter::writeArrayValue(Value const& value)
}
else
{
bool isArrayMultiLine = isMultilineArray(value);
bool const isArrayMultiLine = isMultilineArray(value);
if (isArrayMultiLine)
{
writeWithIndent("[");
indent();
bool hasChildValue = !childValues_.empty();
bool const hasChildValue = !childValues_.empty();
unsigned index = 0;
while (true)
@@ -401,7 +401,7 @@ StyledWriter::writeArrayValue(Value const& value)
bool
StyledWriter::isMultilineArray(Value const& value)
{
int size = value.size();
int const size = value.size();
bool isMultiLine = size * 3 >= rightMargin_;
childValues_.clear();
@@ -449,7 +449,7 @@ StyledWriter::writeIndent()
{
if (!document_.empty())
{
char last = document_[document_.length() - 1];
char const last = document_[document_.length() - 1];
if (last == ' ') // already indented
return;
@@ -573,7 +573,7 @@ StyledStreamWriter::writeValue(Value const& value)
void
StyledStreamWriter::writeArrayValue(Value const& value)
{
unsigned size = value.size();
unsigned const size = value.size();
if (size == 0)
{
@@ -581,13 +581,13 @@ StyledStreamWriter::writeArrayValue(Value const& value)
}
else
{
bool isArrayMultiLine = isMultilineArray(value);
bool const isArrayMultiLine = isMultilineArray(value);
if (isArrayMultiLine)
{
writeWithIndent("[");
indent();
bool hasChildValue = !childValues_.empty();
bool const hasChildValue = !childValues_.empty();
unsigned index = 0;
while (true)
@@ -636,7 +636,7 @@ StyledStreamWriter::writeArrayValue(Value const& value)
bool
StyledStreamWriter::isMultilineArray(Value const& value)
{
int size = value.size();
int const size = value.size();
bool isMultiLine = size * 3 >= rightMargin_;
childValues_.clear();

View File

@@ -127,8 +127,8 @@ ApplyStateTable::apply(
auto curNode = item.second.second;
if ((type == &sfModifiedNode) && (*curNode == *origNode))
continue;
std::uint16_t nodeType = curNode ? curNode->getFieldU16(sfLedgerEntryType)
: origNode->getFieldU16(sfLedgerEntryType);
std::uint16_t const nodeType = curNode ? curNode->getFieldU16(sfLedgerEntryType)
: origNode->getFieldU16(sfLedgerEntryType);
meta.setAffectedNode(item.first, *type, nodeType);
if (type == &sfDeletedNode)
{

View File

@@ -32,7 +32,7 @@ createRoot(
auto
findPreviousPage(ApplyView& view, Keylet const& directory, SLE::ref start)
{
std::uint64_t page = start->getFieldU64(sfIndexPrevious);
std::uint64_t const page = start->getFieldU64(sfIndexPrevious);
auto node = start;

View File

@@ -5,21 +5,21 @@ namespace xrpl {
void
BookListeners::addSubscriber(InfoSub::ref sub)
{
std::lock_guard sl(mLock);
std::lock_guard const sl(mLock);
mListeners[sub->getSeq()] = sub;
}
void
BookListeners::removeSubscriber(std::uint64_t seq)
{
std::lock_guard sl(mLock);
std::lock_guard const sl(mLock);
mListeners.erase(seq);
}
void
BookListeners::publish(MultiApiJson const& jvObj, hash_set<std::uint64_t>& havePublished)
{
std::lock_guard sl(mLock);
std::lock_guard const sl(mLock);
auto it = mListeners.cbegin();
while (it != mListeners.cend())

View File

@@ -21,7 +21,7 @@ CachedViewImpl::read(Keylet const& k) const
auto const digest = [&]() -> std::optional<uint256> {
{
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
auto const iter = map_.find(k.key);
if (iter != map_.end())
{
@@ -57,7 +57,7 @@ CachedViewImpl::read(Keylet const& k) const
// Avoid acquiring this lock unless necessary. It is only necessary if
// the key was not found in the map_. The lock is needed to add the key
// and digest.
std::lock_guard lock(mutex_);
std::lock_guard const lock(mutex_);
map_.emplace(k.key, *digest);
}
if (!sle || !k.check(*sle))

View File

@@ -798,7 +798,7 @@ Ledger::updateSkipList()
if (header_.seq == 0) // genesis ledger has no previous ledger
return;
std::uint32_t prevIndex = header_.seq - 1;
std::uint32_t const prevIndex = header_.seq - 1;
// update record of every 256th ledger
if ((prevIndex & 0xff) == 0)

View File

@@ -58,7 +58,7 @@ makeRulesGivenLedger(
std::unordered_set<uint256, beast::uhash<>> const& presets)
{
Keylet const k = keylet::amendments();
std::optional digest = ledger.digest(k.key);
std::optional const digest = ledger.digest(k.key);
if (digest)
{
auto const sle = ledger.read(k);

View File

@@ -242,7 +242,7 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal)
if (seq == (ledger.seq() - 1))
return ledger.header().parentHash;
if (int diff = ledger.seq() - seq; diff <= 256)
if (int const diff = ledger.seq() - seq; diff <= 256)
{
// Within 256...
auto const hashIndex = ledger.read(keylet::skip());

View File

@@ -16,7 +16,7 @@ offerDelete(ApplyView& view, std::shared_ptr<SLE> const& sle, beast::Journal j)
auto owner = sle->getAccountID(sfAccount);
// Detect legacy directories.
uint256 uDirectory = sle->getFieldH256(sfBookDirectory);
uint256 const uDirectory = sle->getFieldH256(sfBookDirectory);
if (!view.dirRemove(keylet::ownerDir(owner), sle->getFieldU64(sfOwnerNode), offerIndex, false))
{

View File

@@ -275,8 +275,8 @@ trustDelete(
beast::Journal j)
{
// Detect legacy dirs.
std::uint64_t uLowNode = sleRippleState->getFieldU64(sfLowNode);
std::uint64_t uHighNode = sleRippleState->getFieldU64(sfHighNode);
std::uint64_t const uLowNode = sleRippleState->getFieldU64(sfLowNode);
std::uint64_t const uHighNode = sleRippleState->getFieldU64(sfHighNode);
JLOG(j.trace()) << "trustDelete: Deleting ripple line: low";
@@ -374,7 +374,7 @@ issueIOU(
JLOG(j.trace()) << "issueIOU: " << to_string(account) << ": " << amount.getFullText();
bool bSenderHigh = issue.account > account;
bool const bSenderHigh = issue.account > account;
auto const index = keylet::line(issue.account, account, issue.currency);
@@ -428,7 +428,7 @@ issueIOU(
if (!receiverAccount)
return tefINTERNAL; // LCOV_EXCL_LINE
bool noRipple = (receiverAccount->getFlags() & lsfDefaultRipple) == 0;
bool const noRipple = (receiverAccount->getFlags() & lsfDefaultRipple) == 0;
return trustCreate(
view,
@@ -468,7 +468,7 @@ redeemIOU(
JLOG(j.trace()) << "redeemIOU: " << to_string(account) << ": " << amount.getFullText();
bool bSenderHigh = account > issue.account;
bool const bSenderHigh = account > issue.account;
if (auto state = view.peek(keylet::line(account, issue.account, issue.currency)))
{

Some files were not shown because too many files have changed in this diff Show More