chore: Enable clang-tidy coreguidelines checks (#6698)

Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
This commit is contained in:
Alex Kremer
2026-04-01 16:46:14 +01:00
committed by Bart
parent ab7f683b2f
commit f04943fc50
117 changed files with 299 additions and 343 deletions

View File

@@ -78,14 +78,14 @@ Checks: "-*,
bugprone-unused-return-value,
bugprone-unused-local-non-trivial-variable,
bugprone-virtual-near-miss,
# cppcoreguidelines-init-variables, # has issues
# cppcoreguidelines-misleading-capture-default-by-value, # has issues
cppcoreguidelines-init-variables,
cppcoreguidelines-misleading-capture-default-by-value,
cppcoreguidelines-no-suspend-with-lock,
# cppcoreguidelines-pro-type-member-init, # has issues
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-static-cast-downcast,
# cppcoreguidelines-rvalue-reference-param-not-moved, # has issues
# cppcoreguidelines-use-default-member-init, # has issues
# cppcoreguidelines-virtual-class-destructor, # has issues
cppcoreguidelines-rvalue-reference-param-not-moved,
cppcoreguidelines-use-default-member-init,
cppcoreguidelines-virtual-class-destructor,
hicpp-ignored-remove-result,
misc-const-correctness,
misc-definitions-in-headers,

View File

@@ -34,7 +34,7 @@ public:
{
// Insert ourselves at the front of the lock-free linked list
CountedObjects& instance = CountedObjects::getInstance();
Counter* head;
Counter* head = nullptr;
do
{

View File

@@ -93,7 +93,7 @@ class DecayWindow
public:
using time_point = typename Clock::time_point;
explicit DecayWindow(time_point now) : value_(0), when_(now)
explicit DecayWindow(time_point now) : when_(now)
{
}
@@ -125,7 +125,7 @@ private:
when_ = now;
}
double value_;
double value_{0};
time_point when_;
};

View File

@@ -84,7 +84,8 @@ public:
template <class TT>
requires std::convertible_to<TT*, T*>
SharedIntrusive(SharedIntrusive<TT>&& rhs);
SharedIntrusive(
SharedIntrusive<TT>&& rhs); // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
SharedIntrusive&
operator=(SharedIntrusive const& rhs);
@@ -106,7 +107,8 @@ public:
template <class TT>
requires std::convertible_to<TT*, T*>
SharedIntrusive&
operator=(SharedIntrusive<TT>&& rhs);
operator=(
SharedIntrusive<TT>&& rhs); // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
/** Adopt the raw pointer. The strong reference may or may not be
incremented, depending on the TAdoptTag
@@ -314,7 +316,8 @@ public:
template <class TT>
requires std::convertible_to<TT*, T*>
SharedWeakUnion(SharedIntrusive<TT>&& rhs);
SharedWeakUnion(
SharedIntrusive<TT>&& rhs); // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
SharedWeakUnion&
operator=(SharedWeakUnion const& rhs);
@@ -327,7 +330,8 @@ public:
template <class TT>
requires std::convertible_to<TT*, T*>
SharedWeakUnion&
operator=(SharedIntrusive<TT>&& rhs);
operator=(
SharedIntrusive<TT>&& rhs); // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
~SharedWeakUnion();

View File

@@ -73,12 +73,12 @@ struct MantissaRange
enum mantissa_scale { small, large };
explicit constexpr MantissaRange(mantissa_scale scale_)
: min(getMin(scale_)), max(min * 10 - 1), log(logTen(min).value_or(-1)), scale(scale_)
: min(getMin(scale_)), log(logTen(min).value_or(-1)), scale(scale_)
{
}
rep min;
rep max;
rep max{min * 10 - 1};
int log;
mantissa_scale scale;

View File

@@ -91,7 +91,7 @@ class SlabAllocator
std::uint8_t*
allocate() noexcept
{
std::uint8_t* ret;
std::uint8_t* ret = nullptr; // NOLINT(misc-const-correctness)
{
std::lock_guard const l(m_);

View File

@@ -182,8 +182,7 @@ private:
: hook(collector->make_hook(handler))
, size(collector->make_gauge(prefix, "size"))
, hit_rate(collector->make_gauge(prefix, "hit_rate"))
, hits(0)
, misses(0)
{
}
@@ -191,8 +190,8 @@ private:
beast::insight::Gauge size;
beast::insight::Gauge hit_rate;
std::size_t hits;
std::size_t misses;
std::size_t hits{0};
std::size_t misses{0};
};
class KeyOnlyEntry
@@ -294,10 +293,10 @@ private:
clock_type::duration const m_target_age;
// Number of items cached
int m_cache_count;
int m_cache_count{0};
cache_type m_cache; // Hold strong reference to recent objects
std::uint64_t m_hits;
std::uint64_t m_misses;
std::uint64_t m_hits{0};
std::uint64_t m_misses{0};
};
} // namespace xrpl

View File

@@ -36,9 +36,7 @@ inline TaggedCache<
, m_name(name)
, m_target_size(size)
, m_target_age(expiration)
, m_cache_count(0)
, m_hits(0)
, m_misses(0)
{
}

View File

@@ -335,11 +335,13 @@ public:
operator=(std::uint64_t uHost)
{
*this = beast::zero;
// NOLINTBEGIN(cppcoreguidelines-pro-type-member-init)
union
{
unsigned u[2];
std::uint64_t ul;
};
// NOLINTEND(cppcoreguidelines-pro-type-member-init)
// Put in least significant bits.
ul = boost::endian::native_to_big(uHost);
data_[WIDTH - 2] = u[0];
@@ -621,7 +623,7 @@ template <>
inline std::size_t
extract(uint256 const& key)
{
std::size_t result;
std::size_t result = 0;
// Use memcpy to avoid unaligned UB
// (will optimize to equivalent code)
std::memcpy(&result, key.data(), sizeof(std::size_t));

View File

@@ -58,7 +58,7 @@ default_prng()
// The thread-specific PRNGs:
thread_local beast::xor_shift_engine engine = [] {
std::uint64_t seed;
std::uint64_t seed = 0;
{
std::lock_guard const lk(m);
std::uniform_int_distribution<std::uint64_t> distribution{1};

View File

@@ -23,15 +23,15 @@ private:
std::recursive_mutex m_mutex;
std::condition_variable_any m_cond;
std::size_t m_count;
std::size_t m_count{1};
duration const m_period;
boost::asio::io_context& m_ios;
boost::asio::basic_waitable_timer<std::chrono::steady_clock> m_timer;
bool m_cancel;
bool m_cancel{false};
public:
io_latency_probe(duration const& period, boost::asio::io_context& ios)
: m_count(1), m_period(period), m_ios(ios), m_timer(m_ios), m_cancel(false)
: m_period(period), m_ios(ios), m_timer(m_ios)
{
}

View File

@@ -262,7 +262,9 @@ private:
{
}
config_t(config_t&& other, Allocator const& alloc)
config_t(
config_t&& other, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
Allocator const& alloc)
: KeyValueCompare(std::move(other.key_compare()))
, beast::detail::empty_base_optimization<ElementAllocator>(alloc)
, clock(other.clock)
@@ -552,7 +554,10 @@ public:
aged_ordered_container(aged_ordered_container&& other);
aged_ordered_container(aged_ordered_container&& other, Allocator const& alloc);
aged_ordered_container(
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
aged_ordered_container&& other,
Allocator const& alloc);
aged_ordered_container(std::initializer_list<value_type> init, clock_type& clock);
@@ -1290,7 +1295,7 @@ aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::aged_
template <bool IsMulti, bool IsMap, class Key, class T, class Clock, class Compare, class Allocator>
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::aged_ordered_container(
aged_ordered_container&& other,
aged_ordered_container&& other, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
Allocator const& alloc)
: m_config(std::move(other.m_config), alloc)
#if BOOST_VERSION >= 108000

View File

@@ -318,7 +318,9 @@ private:
{
}
config_t(config_t&& other, Allocator const& alloc)
config_t(
config_t&& other, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
Allocator const& alloc)
: ValueHash(std::move(other.hash_function()))
, KeyValueEqual(std::move(other.key_eq()))
, beast::detail::empty_base_optimization<ElementAllocator>(alloc)
@@ -774,7 +776,10 @@ public:
aged_unordered_container(aged_unordered_container&& other);
aged_unordered_container(aged_unordered_container&& other, Allocator const& alloc);
aged_unordered_container(
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
aged_unordered_container&& other,
Allocator const& alloc);
aged_unordered_container(std::initializer_list<value_type> init, clock_type& clock);
@@ -1838,7 +1843,10 @@ template <
class KeyEqual,
class Allocator>
aged_unordered_container<IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>::
aged_unordered_container(aged_unordered_container&& other, Allocator const& alloc)
aged_unordered_container(
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
aged_unordered_container&& other,
Allocator const& alloc)
: m_config(std::move(other.m_config), alloc)
, m_buck(alloc)
, m_cont(m_buck, std::cref(m_config.value_hash()), std::cref(m_config.key_value_equal()))

View File

@@ -187,7 +187,7 @@ public:
bool
push_front(Node* node)
{
bool first;
bool first = false;
Node* old_head = m_head.load(std::memory_order_relaxed);
do
{
@@ -211,7 +211,7 @@ public:
pop_front()
{
Node* node = m_head.load();
Node* new_head;
Node* new_head = nullptr;
do
{
if (node == &m_end)

View File

@@ -23,7 +23,7 @@ private:
// A 64-byte buffer should to be big enough for us
static constexpr std::size_t INTERNAL_BUFFER_SIZE = 64;
alignas(64) std::array<std::uint8_t, INTERNAL_BUFFER_SIZE> buffer_;
alignas(64) std::array<std::uint8_t, INTERNAL_BUFFER_SIZE> buffer_{};
std::span<std::uint8_t> readBuffer_;
std::span<std::uint8_t> writeBuffer_;

View File

@@ -35,10 +35,10 @@ private:
class tests_t : public detail::const_container<std::vector<test>>
{
private:
std::size_t failed_;
std::size_t failed_{0};
public:
tests_t() : failed_(0)
tests_t()
{
}
@@ -167,12 +167,12 @@ public:
class results : public detail::const_container<std::vector<suite_results>>
{
private:
std::size_t m_cases;
std::size_t total_;
std::size_t failed_;
std::size_t m_cases{0};
std::size_t total_{0};
std::size_t failed_{0};
public:
results() : m_cases(0), total_(0), failed_(0)
results()
{
}

View File

@@ -311,7 +311,7 @@ private:
std::string const m_name;
std::recursive_mutex lock_;
Item item_;
Source* parent_;
Source* parent_{nullptr};
List<Item> children_;
public:

View File

@@ -37,7 +37,7 @@ public:
}
private:
result_type s_[2];
result_type s_[2]{};
static result_type
murmurhash3(result_type x);

View File

@@ -92,7 +92,9 @@ private:
++counter_;
}
Substitute(ClosureCounter& counter, Closure&& closure)
Substitute(
ClosureCounter& counter,
Closure&& closure) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
: counter_(counter), closure_(std::forward<Closure>(closure))
{
++counter_;

View File

@@ -7,7 +7,6 @@ JobQueue::Coro::Coro(Coro_create_t, JobQueue& jq, JobType type, std::string cons
: jq_(jq)
, type_(type)
, name_(name)
, running_(false)
, coro_(
// Stack size of 1MB wasn't sufficient for deep calls. ASAN tests flagged the issue. Hence
// increasing the size to 1.5MB.

View File

@@ -45,7 +45,7 @@ public:
JobQueue& jq_;
JobType type_;
std::string name_;
bool running_;
bool running_{false};
std::mutex mutex_;
std::mutex mutex_run_;
std::condition_variable cv_;
@@ -224,7 +224,7 @@ private:
beast::Journal m_journal;
mutable std::mutex m_mutex;
std::uint64_t m_lastJob;
std::uint64_t m_lastJob{0};
std::set<Job> m_jobSet;
JobCounter jobCounter_;
std::atomic_bool stopping_{false};
@@ -233,7 +233,7 @@ private:
JobTypeData m_invalidJobData;
// The number of jobs currently in processTask()
int m_processCount;
int m_processCount{0};
// The number of suspended coroutines
int nSuspend_ = 0;

View File

@@ -19,13 +19,13 @@ public:
JobTypeInfo const& info;
/* The number of jobs waiting */
int waiting;
int waiting{0};
/* The number presently running */
int running;
int running{0};
/* And the number we deferred executing because of job limits */
int deferred;
int deferred{0};
/* Notification callbacks */
beast::insight::Event dequeue;
@@ -35,12 +35,8 @@ public:
JobTypeInfo const& info_,
beast::insight::Collector::ptr const& collector,
Logs& logs) noexcept
: m_load(logs.journal("LoadMonitor"))
, m_collector(collector)
, info(info_)
, waiting(0)
, running(0)
, deferred(0)
: m_load(logs.journal("LoadMonitor")), m_collector(collector), info(info_)
{
m_load.setTargetLatency(info.getAverageLatency(), info.getPeakLatency());

View File

@@ -36,10 +36,10 @@ public:
{
Stats();
std::uint64_t count;
std::uint64_t count{0};
std::chrono::milliseconds latencyAvg;
std::chrono::milliseconds latencyPeak;
bool isOverloaded;
bool isOverloaded{false};
};
Stats
@@ -54,8 +54,8 @@ private:
std::mutex mutex_;
std::uint64_t mCounts;
int mLatencyEvents;
std::uint64_t mCounts{0};
int mLatencyEvents{0};
std::chrono::milliseconds mLatencyMSAvg;
std::chrono::milliseconds mLatencyMSPeak;
std::chrono::milliseconds mTargetLatencyAvg;

View File

@@ -92,7 +92,7 @@ public:
private:
beast::Journal mutable journal_;
std::mutex mutable mutex_;
DatabaseCon* connection_;
DatabaseCon* connection_{};
std::unordered_set<PeerReservation, beast::uhash<>, KeyEqual> table_;
};

View File

@@ -183,8 +183,8 @@ private:
std::thread thread_;
std::mutex mutex_;
std::condition_variable wakeup_;
int wakeCount_; // how many times to un-pause
bool shouldExit_;
int wakeCount_{0}; // how many times to un-pause
bool shouldExit_{false};
};
private:
@@ -197,9 +197,9 @@ private:
std::string m_threadNames; // The name to give each thread
std::condition_variable m_cv; // signaled when all threads paused
std::mutex m_mut;
bool m_allPaused;
bool m_allPaused{true};
semaphore m_semaphore; // each pending task is 1 resource
int m_numberOfThreads; // how many we want active now
int m_numberOfThreads{0}; // how many we want active now
std::atomic<int> m_activeCount; // to know when all are paused
std::atomic<int> m_pauseCount; // how many threads need to pause now
std::atomic<int> m_runningTaskCount; // how many calls to processTask() active

View File

@@ -103,9 +103,9 @@ private:
public:
explicit ErrorInfo() = default;
Token token_;
Token token_{};
std::string message_;
Location extra_;
Location extra_{};
};
using Errors = std::deque<ErrorInfo>;
@@ -173,11 +173,11 @@ private:
Nodes nodes_;
Errors errors_;
std::string document_;
Location begin_;
Location end_;
Location current_;
Location lastValueEnd_;
Value* lastValue_;
Location begin_{};
Location end_{};
Location current_{};
Location lastValueEnd_{};
Value* lastValue_{};
};
template <class BufferSequence>

View File

@@ -106,8 +106,8 @@ private:
ChildValues childValues_;
std::string document_;
std::string indentString_;
int rightMargin_;
int indentSize_;
int rightMargin_{74};
int indentSize_{3};
bool addChildValues_{};
};
@@ -171,9 +171,9 @@ private:
using ChildValues = std::vector<std::string>;
ChildValues childValues_;
std::ostream* document_;
std::ostream* document_{nullptr};
std::string indentString_;
int rightMargin_;
int rightMargin_{74};
std::string indentation_;
bool addChildValues_{};
};

View File

@@ -16,7 +16,7 @@ struct FetchReport
{
}
std::chrono::milliseconds elapsed;
std::chrono::milliseconds elapsed{};
FetchType const fetchType;
bool wasFound = false;
};

View File

@@ -71,8 +71,8 @@ private:
Scheduler& m_scheduler;
LockType mWriteMutex;
CondvarType mWriteCondition;
int mWriteLoad;
bool mWritePending;
int mWriteLoad{0};
bool mWritePending{false};
Batch mWriteSet;
};

View File

@@ -35,7 +35,7 @@ namespace NodeStore {
class EncodedBlob
{
/** The 32-byte key of the serialized object. */
std::array<std::uint8_t, 32> key_;
std::array<std::uint8_t, 32> key_{};
/** A pre-allocated buffer for the serialized object.
@@ -43,7 +43,8 @@ class EncodedBlob
1024 more bytes. The precise size is calculated automatically
at compile time so as to avoid wasting space on padding bytes.
*/
std::array<std::uint8_t, boost::alignment::align_up(9 + 1024, alignof(std::uint32_t))> payload_;
std::array<std::uint8_t, boost::alignment::align_up(9 + 1024, alignof(std::uint32_t))>
payload_{};
/** The size of the serialized data. */
std::uint32_t size_;

View File

@@ -56,7 +56,7 @@ lz4_compress(void const* in, std::size_t in_size, BufferFactory&& bf)
using std::runtime_error;
using namespace nudb::detail;
std::pair<void const*, std::size_t> result;
std::array<std::uint8_t, varint_traits<std::size_t>::max> vi;
std::array<std::uint8_t, varint_traits<std::size_t>::max> vi{};
auto const n = write_varint(vi.data(), in_size);
auto const out_max = LZ4_compressBound(in_size);
std::uint8_t* out = reinterpret_cast<std::uint8_t*>(bf(n + out_max));
@@ -88,7 +88,7 @@ nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf)
using namespace nudb::detail;
std::uint8_t const* p = reinterpret_cast<std::uint8_t const*>(in);
std::size_t type;
std::size_t type = 0;
auto const vn = read_varint(p, in_size, type);
if (vn == 0)
Throw<std::runtime_error>("nodeobject decompress");
@@ -117,7 +117,7 @@ nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf)
"nodeobject codec v1: short inner node size: " + std::string("in_size = ") +
std::to_string(in_size) + " hs = " + std::to_string(hs));
istream is(p, in_size);
std::uint16_t mask;
std::uint16_t mask = 0;
read<std::uint16_t>(is, mask); // Mask
in_size -= hs;
result.second = 525;
@@ -196,10 +196,10 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf)
if (in_size == 525)
{
istream is(in, in_size);
std::uint32_t index;
std::uint32_t unused;
std::uint8_t kind;
std::uint32_t prefix;
std::uint32_t index = 0;
std::uint32_t unused = 0;
std::uint8_t kind = 0;
std::uint32_t prefix = 0;
read<std::uint32_t>(is, index);
read<std::uint32_t>(is, unused);
read<std::uint8_t>(is, kind);
@@ -208,7 +208,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf)
{
std::size_t n = 0;
std::uint16_t mask = 0;
std::array<std::uint8_t, 512> vh;
std::array<std::uint8_t, 512> vh{};
for (unsigned bit = 0x8000; bit; bit >>= 1)
{
void const* const h = is(32);
@@ -247,7 +247,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf)
}
}
std::array<std::uint8_t, varint_traits<std::size_t>::max> vi;
std::array<std::uint8_t, varint_traits<std::size_t>::max> vi{};
constexpr std::size_t codecType = 1;
auto const vn = write_varint(vi.data(), codecType);
@@ -257,7 +257,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf)
// case 0 was uncompressed data; we always compress now.
case 1: // lz4
{
std::uint8_t* p;
std::uint8_t* p = nullptr;
auto const lzr = NodeStore::lz4_compress(in, in_size, [&p, &vn, &bf](std::size_t n) {
p = reinterpret_cast<std::uint8_t*>(bf(vn + n));
return p + vn;
@@ -287,10 +287,10 @@ filter_inner(void* in, std::size_t in_size)
if (in_size == 525)
{
istream is(in, in_size);
std::uint32_t index;
std::uint32_t unused;
std::uint8_t kind;
std::uint32_t prefix;
std::uint32_t index = 0;
std::uint32_t unused = 0;
std::uint8_t kind = 0;
std::uint32_t prefix = 0;
read<std::uint32_t>(is, index);
read<std::uint32_t>(is, unused);
read<std::uint8_t>(is, kind);

View File

@@ -26,8 +26,8 @@ class IOUAmount : private boost::totally_ordered<IOUAmount>, private boost::addi
private:
using mantissa_type = std::int64_t;
using exponent_type = int;
mantissa_type mantissa_;
exponent_type exponent_;
mantissa_type mantissa_{};
exponent_type exponent_{};
/** Adjusts the mantissa and exponent to the proper range.

View File

@@ -363,11 +363,12 @@ uint256
getTicketIndex(AccountID const& account, SeqProxy ticketSeq);
template <class... keyletParams>
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
struct keyletDesc
{
std::function<Keylet(keyletParams...)> function;
Json::StaticString expectedLEName;
bool includeInTests;
bool includeInTests{};
};
// This list should include all of the keylet functions that take a single

View File

@@ -56,8 +56,8 @@ struct TAmounts
return *this;
}
In in;
Out out;
In in{};
Out out{};
};
using Amounts = TAmounts<STAmount, STAmount>;

View File

@@ -35,9 +35,9 @@ public:
private:
Asset mAsset;
mantissa_type mValue;
mantissa_type mValue{};
exponent_type mOffset;
bool mIsNegative;
bool mIsNegative{};
public:
using value_type = STAmount;

View File

@@ -86,7 +86,9 @@ inline STLedgerEntry::STLedgerEntry(LedgerEntryType type, uint256 const& key)
{
}
inline STLedgerEntry::STLedgerEntry(SerialIter&& sit, uint256 const& index)
inline STLedgerEntry::STLedgerEntry(
SerialIter&& sit, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
uint256 const& index)
: STLedgerEntry(sit, index)
{
}

View File

@@ -671,7 +671,7 @@ public:
OptionalProxy&
operator=(std::nullopt_t const&);
OptionalProxy&
operator=(optional_type&& v);
operator=(optional_type&& v); // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
OptionalProxy&
operator=(optional_type const& v);
@@ -766,7 +766,7 @@ STObject::Proxy<T>::assign(U&& u)
st_->makeFieldAbsent(*f_);
return;
}
T* t;
T* t = nullptr;
if (style_ == soeINVALID)
t = dynamic_cast<T*>(st_->getPField(*f_, true));
else
@@ -851,7 +851,9 @@ STObject::OptionalProxy<T>::operator=(std::nullopt_t const&) -> OptionalProxy&
template <class T>
auto
STObject::OptionalProxy<T>::operator=(optional_type&& v) -> OptionalProxy&
STObject::OptionalProxy<T>::operator=(
optional_type&& v) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
-> OptionalProxy&
{
if (v)
this->assign(std::move(*v));
@@ -930,6 +932,7 @@ STObject::Transform::operator()(detail::STVar const& e) const
//------------------------------------------------------------------------------
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
inline STObject::STObject(SerialIter&& sit, SField const& name) : STObject(sit, name)
{
}

View File

@@ -179,7 +179,8 @@ sterilize(STTx const& stx);
bool
isPseudoTx(STObject const& tx);
inline STTx::STTx(SerialIter&& sit) : STTx(sit)
inline STTx::STTx(SerialIter&& sit) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
: STTx(sit)
{
}

View File

@@ -50,7 +50,7 @@ public:
STVar&
operator=(STVar&& rhs);
STVar(STBase&& t)
STVar(STBase&& t) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
{
p_ = t.move(max_size, &d_);
}

View File

@@ -59,7 +59,7 @@ inplace_bigint_add(std::span<std::uint64_t> a, std::uint64_t b)
return TokenCodecErrc::inputTooSmall;
}
std::uint64_t carry;
std::uint64_t carry = 0;
std::tie(a[0], carry) = carrying_add(a[0], b);
for (auto& v : a.subspan(1))
@@ -162,7 +162,7 @@ b58_10_to_b58_be(std::uint64_t input)
int i = 0;
while (input > 0)
{
std::uint64_t rem;
std::uint64_t rem = 0;
std::tie(input, rem) = div_rem(input, 58);
result[resultSize - 1 - i] = rem;
i += 1;

View File

@@ -112,7 +112,7 @@ getOrThrow(Json::Value const& v, xrpl::SField const& field)
{
auto const s = inner.asString();
// parse as hex
std::uint64_t val;
std::uint64_t val = 0;
auto [p, ec] = std::from_chars(s.data(), s.data() + s.size(), val, 16);

View File

@@ -39,7 +39,7 @@ constexpr std::uint16_t const flagMutable = 0x0010;
inline std::uint16_t
getFlags(uint256 const& id)
{
std::uint16_t flags;
std::uint16_t flags = 0;
memcpy(&flags, id.begin(), 2);
return boost::endian::big_to_native(flags);
}
@@ -47,7 +47,7 @@ getFlags(uint256 const& id)
inline std::uint16_t
getTransferFee(uint256 const& id)
{
std::uint16_t fee;
std::uint16_t fee = 0;
memcpy(&fee, id.begin() + 2, 2);
return boost::endian::big_to_native(fee);
}
@@ -55,7 +55,7 @@ getTransferFee(uint256 const& id)
inline std::uint32_t
getSerial(uint256 const& id)
{
std::uint32_t seq;
std::uint32_t seq = 0;
memcpy(&seq, id.begin() + 28, 4);
return boost::endian::big_to_native(seq);
}
@@ -87,7 +87,7 @@ cipheredTaxon(std::uint32_t tokenSeq, Taxon taxon)
inline Taxon
getTaxon(uint256 const& id)
{
std::uint32_t taxon;
std::uint32_t taxon = 0;
memcpy(&taxon, id.begin() + 24, 4);
taxon = boost::endian::big_to_native(taxon);

View File

@@ -51,19 +51,19 @@ public:
AccountID const& account;
/// Ledger sequence range to search. A value of 0 for min or max
/// means unbounded in that direction (no constraint applied).
LedgerRange ledgerRange;
std::uint32_t offset;
std::uint32_t limit;
bool bUnlimited;
LedgerRange ledgerRange{};
std::uint32_t offset = 0;
std::uint32_t limit = 0;
bool bUnlimited{};
};
struct AccountTxPageOptions
{
AccountID const& account;
LedgerRange ledgerRange;
LedgerRange ledgerRange{};
std::optional<AccountTxMarker> marker;
std::uint32_t limit;
bool bAdmin;
std::uint32_t limit = 0;
bool bAdmin = false;
};
using AccountTx = std::pair<std::shared_ptr<Transaction>, std::shared_ptr<TxMeta>>;
@@ -88,8 +88,8 @@ public:
struct AccountTxResult
{
std::variant<AccountTxs, MetaTxsList> transactions;
LedgerRange ledgerRange;
uint32_t limit;
LedgerRange ledgerRange{};
uint32_t limit = 0;
std::optional<AccountTxMarker> marker;
};

View File

@@ -17,7 +17,7 @@ struct Gossip
{
explicit Item() = default;
int balance;
int balance{};
beast::IP::Endpoint address;
};

View File

@@ -62,7 +62,7 @@ struct Entry : public beast::List<Entry>::Node
std::optional<PublicKey> publicKey;
// Back pointer to the map key (bit of a hack here)
Key const* key;
Key const* key{};
// Number of Consumer references
int refcount;

View File

@@ -13,7 +13,7 @@ struct Import
{
explicit Item() = default;
int balance;
int balance{};
Consumer consumer;
};

View File

@@ -26,10 +26,6 @@ class LoadFeeTrack final
public:
explicit LoadFeeTrack(beast::Journal journal = beast::Journal(beast::Journal::getNullSink()))
: j_(journal)
, localTxnLoadFee_(lftNormalFee)
, remoteTxnLoadFee_(lftNormalFee)
, clusterTxnLoadFee_(lftNormalFee)
, raiseCount_(0)
{
}
@@ -124,10 +120,10 @@ private:
beast::Journal const j_;
std::mutex mutable lock_;
std::uint32_t localTxnLoadFee_; // Scale factor, lftNormalFee = normal fee
std::uint32_t remoteTxnLoadFee_; // Scale factor, lftNormalFee = normal fee
std::uint32_t clusterTxnLoadFee_; // Scale factor, lftNormalFee = normal fee
std::uint32_t raiseCount_;
std::uint32_t localTxnLoadFee_{lftNormalFee}; // Scale factor, lftNormalFee = normal fee
std::uint32_t remoteTxnLoadFee_{lftNormalFee}; // Scale factor, lftNormalFee = normal fee
std::uint32_t clusterTxnLoadFee_{lftNormalFee}; // Scale factor, lftNormalFee = normal fee
std::uint32_t raiseCount_{0};
};
//------------------------------------------------------------------------------

View File

@@ -54,7 +54,7 @@ struct Port
int limit = 0;
// Websocket disconnects if send queue exceeds this limit
std::uint16_t ws_queue_limit;
std::uint16_t ws_queue_limit{};
// Returns `true` if any websocket protocols are specified
bool
@@ -90,7 +90,7 @@ struct ParsedPort
std::string ssl_ciphers;
boost::beast::websocket::permessage_deflate pmd_options;
int limit = 0;
std::uint16_t ws_queue_limit;
std::uint16_t ws_queue_limit{};
std::optional<boost::asio::ip::address> ip;
std::optional<std::uint16_t> port;

View File

@@ -12,7 +12,7 @@ struct SavedState
{
std::string writableDb;
std::string archiveDb;
LedgerIndex lastRotated;
LedgerIndex lastRotated{};
};
/**

View File

@@ -48,14 +48,14 @@ protected:
struct buffer
{
buffer(void const* ptr, std::size_t len) : data(new char[len]), bytes(len), used(0)
buffer(void const* ptr, std::size_t len) : data(new char[len]), bytes(len)
{
memcpy(data.get(), ptr, len);
}
std::unique_ptr<char[]> data;
std::size_t bytes;
std::size_t used;
std::size_t used{0};
};
Port const& port_;

View File

@@ -88,8 +88,12 @@ private:
boost::asio::io_context& ioc_;
acceptor_type acceptor_;
boost::asio::strand<boost::asio::io_context::executor_type> strand_;
bool ssl_;
bool plain_;
bool ssl_{
port_.protocol.count("https") > 0 || port_.protocol.count("wss") > 0 ||
port_.protocol.count("wss2") > 0 || port_.protocol.count("peer") > 0};
bool plain_{
port_.protocol.count("http") > 0 || port_.protocol.count("ws") > 0 ||
port_.protocol.count("ws2")};
static constexpr std::chrono::milliseconds INITIAL_ACCEPT_DELAY{50};
static constexpr std::chrono::milliseconds MAX_ACCEPT_DELAY{2000};
std::chrono::milliseconds accept_delay_{INITIAL_ACCEPT_DELAY};
@@ -274,12 +278,6 @@ Door<Handler>::Door(
, ioc_(io_context)
, acceptor_(io_context)
, strand_(boost::asio::make_strand(io_context))
, ssl_(
port_.protocol.count("https") > 0 || port_.protocol.count("wss") > 0 ||
port_.protocol.count("wss2") > 0 || port_.protocol.count("peer") > 0)
, plain_(
port_.protocol.count("http") > 0 || port_.protocol.count("ws") > 0 ||
port_.protocol.count("ws2"))
, backoff_timer_(io_context)
{
reOpen();
@@ -397,7 +395,7 @@ Door<Handler>::query_fd_stats() const
return std::nullopt;
#else
FDStats s;
struct rlimit rl;
struct rlimit rl{};
if (getrlimit(RLIMIT_NOFILE, &rl) != 0 || rl.rlim_cur == RLIM_INFINITY)
return std::nullopt;
s.limit = static_cast<std::uint64_t>(rl.rlim_cur);

View File

@@ -74,7 +74,7 @@ private:
std::vector<Port> ports_;
std::vector<std::weak_ptr<Door<Handler>>> list_;
int high_ = 0;
std::array<std::size_t, 64> hist_;
std::array<std::size_t, 64> hist_{};
io_list ios_;

View File

@@ -116,12 +116,13 @@ protected:
AccountID const account_;
XRPAmount preFeeBalance_{}; // Balance before fees.
virtual ~Transactor() = default;
Transactor(Transactor const&) = delete;
Transactor&
operator=(Transactor const&) = delete;
public:
virtual ~Transactor() = default;
enum ConsequencesFactoryType { Normal, Blocker, Custom };
/** Process the transaction. */
ApplyResult

View File

@@ -15,12 +15,12 @@ class ValidAMM
std::optional<AccountID> ammAccount_;
std::optional<STAmount> lptAMMBalanceAfter_;
std::optional<STAmount> lptAMMBalanceBefore_;
bool ammPoolChanged_;
bool ammPoolChanged_{false};
public:
enum class ZeroAllowed : bool { No = false, Yes = true };
ValidAMM() : ammPoolChanged_{false}
ValidAMM()
{
}
void

View File

@@ -37,7 +37,7 @@ private:
// else the amounts quality
Quality const quality_;
// AMM offer can be consumed once at a given iteration
bool consumed_;
bool consumed_{false};
public:
AMMOffer(

View File

@@ -16,7 +16,7 @@ class BookTip
{
private:
ApplyView& view_;
bool m_valid;
bool m_valid{false};
uint256 m_book;
uint256 m_end;
uint256 m_dir;

View File

@@ -32,10 +32,10 @@ class TOffer : private TOfferBase<TIn, TOut>
{
private:
SLE::pointer m_entry;
Quality m_quality;
Quality m_quality{};
AccountID m_account;
TAmounts<TIn, TOut> m_amounts;
TAmounts<TIn, TOut> m_amounts{};
void
setFieldAmounts();

View File

@@ -19,11 +19,11 @@ public:
{
private:
std::uint32_t const limit_;
std::uint32_t count_;
std::uint32_t count_{0};
beast::Journal j_;
public:
StepCounter(std::uint32_t limit, beast::Journal j) : limit_(limit), count_(0), j_(j)
StepCounter(std::uint32_t limit, beast::Journal j) : limit_(limit), j_(j)
{
}

View File

@@ -12,7 +12,7 @@ struct AmountSpec
{
explicit AmountSpec() = default;
bool native;
bool native{};
union
{
XRPAmount xrp;

View File

@@ -27,7 +27,7 @@ namespace xrpl {
template <class TInAmt, class TOutAmt>
struct StrandResult
{
bool success; ///< Strand succeeded
bool success = false; ///< Strand succeeded
TInAmt in = beast::zero; ///< Currency amount in
TOutAmt out = beast::zero; ///< Currency amount out
std::optional<PaymentSandbox> sandbox; ///< Resulting Sandbox state
@@ -61,7 +61,7 @@ struct StrandResult
}
StrandResult(Strand const& strand, boost::container::flat_set<uint256> ofrsToRm_)
: success(false), ofrsToRm(std::move(ofrsToRm_)), ofrsUsed(offersUsed(strand))
: ofrsToRm(std::move(ofrsToRm_)), ofrsUsed(offersUsed(strand))
{
}
};

View File

@@ -143,7 +143,7 @@ struct LoanProperties
// - A minimum scale required to represent the periodic payment accurately
// All loan state values (principal, interest, fees) are rounded to this
// scale.
std::int32_t loanScale;
std::int32_t loanScale{};
// The principal portion of the first payment.
Number firstPaymentPrincipal;

View File

@@ -10,7 +10,7 @@ struct MPTCreateArgs
{
std::optional<XRPAmount> priorBalance;
AccountID const& account;
std::uint32_t sequence;
std::uint32_t sequence = 0;
std::uint32_t flags = 0;
std::optional<std::uint64_t> maxAmount{};
std::optional<std::uint8_t> assetScale{};

View File

@@ -151,8 +151,7 @@ PropertyStream::Set::stream() const
//
//------------------------------------------------------------------------------
PropertyStream::Source::Source(std::string const& name)
: m_name(name), item_(this), parent_(nullptr)
PropertyStream::Source::Source(std::string const& name) : m_name(name), item_(this)
{
}

View File

@@ -13,9 +13,7 @@ JobQueue::JobQueue(
Logs& logs,
perf::PerfLog& perfLog)
: m_journal(journal)
, m_lastJob(0)
, m_invalidJobData(JobTypes::instance().getInvalid(), collector, logs)
, m_processCount(0)
, m_workers(*this, &perfLog, "JobQueue", threadCount)
, perfLog_(perfLog)
, m_collector(collector)

View File

@@ -15,16 +15,14 @@ TODO
//------------------------------------------------------------------------------
LoadMonitor::Stats::Stats() : count(0), latencyAvg(0), latencyPeak(0), isOverloaded(false)
LoadMonitor::Stats::Stats() : latencyAvg(0), latencyPeak(0)
{
}
//------------------------------------------------------------------------------
LoadMonitor::LoadMonitor(beast::Journal j)
: mCounts(0)
, mLatencyEvents(0)
, mLatencyMSAvg(0)
: mLatencyMSAvg(0)
, mLatencyMSPeak(0)
, mTargetLatencyAvg(0)
, mTargetLatencyPk(0)

View File

@@ -12,9 +12,7 @@ Workers::Workers(
: m_callback(callback)
, perfLog_(perfLog)
, m_threadNames(threadNames)
, m_allPaused(true)
, m_semaphore(0)
, m_numberOfThreads(0)
, m_activeCount(0)
, m_pauseCount(0)
, m_runningTaskCount(0)
@@ -138,11 +136,8 @@ Workers::deleteWorkers(beast::LockFreeStack<Worker>& stack)
//------------------------------------------------------------------------------
Workers::Worker::Worker(Workers& workers, std::string const& threadName, int const instance)
: m_workers{workers}
, threadName_{threadName}
, instance_{instance}
, wakeCount_{0}
, shouldExit_{false}
: m_workers{workers}, threadName_{threadName}, instance_{instance}
{
thread_ = std::thread{&Workers::Worker::run, this};
}

View File

@@ -252,7 +252,7 @@ FastWriter::writeValue(Value const& value)
// Class StyledWriter
// //////////////////////////////////////////////////////////////////
StyledWriter::StyledWriter() : rightMargin_(74), indentSize_(3)
StyledWriter::StyledWriter()
{
}
@@ -486,8 +486,7 @@ StyledWriter::unindent()
// Class StyledStreamWriter
// //////////////////////////////////////////////////////////////////
StyledStreamWriter::StyledStreamWriter(std::string indentation)
: document_(nullptr), rightMargin_(74), indentation_(indentation)
StyledStreamWriter::StyledStreamWriter(std::string indentation) : indentation_(indentation)
{
}

View File

@@ -4,7 +4,7 @@ namespace xrpl {
namespace NodeStore {
BatchWriter::BatchWriter(Callback& callback, Scheduler& scheduler)
: m_callback(callback), m_scheduler(scheduler), mWriteLoad(0), mWritePending(false)
: m_callback(callback), m_scheduler(scheduler)
{
mWriteSet.reserve(batchWritePreallocationSize);
}

View File

@@ -181,7 +181,7 @@ STAmount::STAmount(SerialIter& sit, SField const& name) : STBase(name)
}
STAmount::STAmount(SField const& name, std::int64_t mantissa)
: STBase(name), mAsset(xrpIssue()), mValue(0), mOffset(0), mIsNegative(false)
: STBase(name), mAsset(xrpIssue()), mOffset(0)
{
set(mantissa);
}

View File

@@ -10,11 +10,8 @@ AMMOffer<TIn, TOut>::AMMOffer(
TAmounts<TIn, TOut> const& amounts,
TAmounts<TIn, TOut> const& balances,
Quality const& quality)
: ammLiquidity_(ammLiquidity)
, amounts_(amounts)
, balances_(balances)
, quality_(quality)
, consumed_(false)
: ammLiquidity_(ammLiquidity), amounts_(amounts), balances_(balances), quality_(quality)
{
}

View File

@@ -5,7 +5,7 @@
namespace xrpl {
BookTip::BookTip(ApplyView& view, Book const& book)
: view_(view), m_valid(false), m_book(getBookBase(book)), m_end(getQualityNext(m_book))
: view_(view), m_book(getBookBase(book)), m_end(getQualityNext(m_book))
{
}

View File

@@ -231,7 +231,7 @@ struct Peer
// Number of proposers in the prior round
std::size_t prevProposers = 0;
// Duration of prior round
std::chrono::milliseconds prevRoundTime;
std::chrono::milliseconds prevRoundTime{};
// Quorum of validations needed for a ledger to be fully validated
// TODO: Use the logic in ValidatorList to set this dynamically
@@ -501,16 +501,10 @@ struct Peer
NetClock::duration const& closeResolution,
ConsensusCloseTimes const& rawCloseTimes,
ConsensusMode const& mode,
Json::Value&& consensusJson)
Json::Value const& consensusJson)
{
onAccept(
result,
prevLedger,
closeResolution,
rawCloseTimes,
mode,
std::move(consensusJson),
validating());
result, prevLedger, closeResolution, rawCloseTimes, mode, consensusJson, validating());
}
void
@@ -520,10 +514,10 @@ struct Peer
NetClock::duration const& closeResolution,
ConsensusCloseTimes const& rawCloseTimes,
ConsensusMode const& mode,
Json::Value&& consensusJson,
Json::Value const& consensusJson,
bool const validating)
{
schedule(delays.ledgerAccept, [=, this]() {
schedule(delays.ledgerAccept, [mode, result, prevLedger, closeResolution, this]() {
bool const proposing = mode == ConsensusMode::proposing;
bool const consensusFail = result.state == ConsensusState::MovedOn;

View File

@@ -100,7 +100,8 @@ public:
{
}
TxSet(MutableTxSet&& m) : txs_{std::move(m.txs_)}, id_{calcID(txs_)}
TxSet(MutableTxSet&& m) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
: txs_{m.txs_}, id_{calcID(txs_)}
{
}
@@ -161,7 +162,7 @@ private:
TxSetType txs_;
//! The unique ID of this tx set
ID id_;
ID id_{};
};
//------------------------------------------------------------------------------

View File

@@ -24,7 +24,7 @@ private:
operator=(SignSubmitRunner&&) = delete;
SignSubmitRunner(Env& env, JTx&& jt, std::source_location loc)
: env_(env), jt_(jt), loc_(loc)
: env_(env), jt_(std::move(jt)), loc_(loc)
{
}

View File

@@ -99,7 +99,7 @@ private:
static inline std::uint32_t fee = 0;
Env& env_;
AccountID owner_;
std::uint32_t documentID_;
std::uint32_t documentID_{};
private:
void

View File

@@ -12,7 +12,7 @@ namespace detail {
class flags_helper
{
protected:
std::uint32_t mask_;
std::uint32_t mask_{0};
private:
void
@@ -79,7 +79,7 @@ private:
protected:
template <class... Args>
flags_helper(Args... args) : mask_(0)
flags_helper(Args... args)
{
set_args(args...);
}

View File

@@ -12,7 +12,7 @@ namespace test {
namespace jtx {
namespace oracle {
Oracle::Oracle(Env& env, CreateArg const& arg, bool submit) : env_(env), documentID_{}
Oracle::Oracle(Env& env, CreateArg const& arg, bool submit) : env_(env)
{
// LastUpdateTime is checked to be in range
// {close-maxLastUpdateTimeDelta, close+maxLastUpdateTimeDelta}.

View File

@@ -8,12 +8,14 @@ namespace test {
namespace jtx {
qualityInPercent::qualityInPercent(double percent)
// NOLINTNEXTLINE(cppcoreguidelines-use-default-member-init)
: qIn_(static_cast<std::uint32_t>((percent / 100) * QUALITY_ONE))
{
assert(percent <= 400 && percent >= 0);
}
qualityOutPercent::qualityOutPercent(double percent)
// NOLINTNEXTLINE(cppcoreguidelines-use-default-member-init)
: qOut_(static_cast<std::uint32_t>((percent / 100) * QUALITY_ONE))
{
assert(percent <= 400 && percent >= 0);

View File

@@ -413,7 +413,6 @@ XChainBridgeObjects::XChainBridgeObjects()
}
return r;
}())
, quorum(UT_XCHAIN_DEFAULT_QUORUM)
, reward(XRP(1))
, split_reward_quorum(divide(reward, STAmount(UT_XCHAIN_DEFAULT_QUORUM), reward.issue()))
, split_reward_everyone(divide(reward, STAmount(UT_XCHAIN_DEFAULT_NUM_SIGNERS), reward.issue()))

View File

@@ -25,7 +25,7 @@ public:
class qualityInPercent
{
private:
std::uint32_t qIn_;
std::uint32_t qIn_; // NOLINT(cppcoreguidelines-use-default-member-init)
public:
explicit qualityInPercent(double percent);
@@ -53,7 +53,7 @@ public:
class qualityOutPercent
{
private:
std::uint32_t qOut_;
std::uint32_t qOut_; // NOLINT(cppcoreguidelines-use-default-member-init)
public:
explicit qualityOutPercent(double percent);

View File

@@ -170,7 +170,7 @@ struct XChainBridgeObjects
std::vector<signer> const alt_signers;
std::vector<Account> const payee;
std::vector<Account> const payees;
std::uint32_t const quorum;
std::uint32_t const quorum{UT_XCHAIN_DEFAULT_QUORUM};
STAmount const reward; // 1 xrp
STAmount const split_reward_quorum; // 250,000 drops

View File

@@ -152,11 +152,11 @@ private:
clock_type::time_point mLastAction;
std::shared_ptr<Ledger> mLedger;
bool mHaveHeader;
bool mHaveState;
bool mHaveTransactions;
bool mSignaled;
bool mByHash;
bool mHaveHeader{false};
bool mHaveState{false};
bool mHaveTransactions{false};
bool mSignaled{false};
bool mByHash{true};
std::uint32_t mSeq;
Reason const mReason;
@@ -168,7 +168,7 @@ private:
std::mutex mReceivedDataLock;
std::vector<std::pair<std::weak_ptr<Peer>, std::shared_ptr<protocol::TMLedgerData>>>
mReceivedData;
bool mReceiveDispatched;
bool mReceiveDispatched{false};
std::unique_ptr<PeerSet> mPeerSet;
};

View File

@@ -67,14 +67,8 @@ InboundLedger::InboundLedger(
{jtLEDGER_DATA, "InboundLedger", 5},
app.getJournal("InboundLedger"))
, m_clock(clock)
, mHaveHeader(false)
, mHaveState(false)
, mHaveTransactions(false)
, mSignaled(false)
, mByHash(true)
, mSeq(seq)
, mReason(reason)
, mReceiveDispatched(false)
, mPeerSet(std::move(peerSet))
{
JLOG(journal_.trace()) << "Acquiring ledger " << hash_;

View File

@@ -15,10 +15,6 @@ TimeoutCounter::TimeoutCounter(
: app_(app)
, journal_(journal)
, hash_(hash)
, timeouts_(0)
, complete_(false)
, failed_(false)
, progress_(false)
, timerInterval_(interval)
, queueJobParameter_(std::move(jobParameter))
, timer_(app_.getIOContext())

View File

@@ -59,6 +59,8 @@ public:
virtual void
cancel();
virtual ~TimeoutCounter() = default;
protected:
using ScopedLockType = std::unique_lock<std::recursive_mutex>;
@@ -76,8 +78,6 @@ protected:
QueueJobParameter&& jobParameter,
beast::Journal journal);
virtual ~TimeoutCounter() = default;
/** Schedule a call to queueJob() after mTimerInterval. */
void
setTimer(ScopedLockType&);
@@ -109,11 +109,11 @@ protected:
/** The hash of the object (in practice, always a ledger) we are trying to
* fetch. */
uint256 const hash_;
int timeouts_;
bool complete_;
bool failed_;
int timeouts_{0};
bool complete_{false};
bool failed_{false};
/** Whether forward progress has been made. */
bool progress_;
bool progress_{false};
/** The minimum time to wait between calls to execute(). */
std::chrono::milliseconds timerInterval_;

View File

@@ -31,7 +31,6 @@ TransactionAcquire::TransactionAcquire(
TX_ACQUIRE_TIMEOUT,
{jtTXN_DATA, "TxAcq", {}},
app.getJournal("TransactionAcquire"))
, mHaveRoot(false)
, mPeerSet(std::move(peerSet))
{
mMap = std::make_shared<SHAMap>(SHAMapType::TRANSACTION, hash, app_.getNodeFamily());

View File

@@ -31,7 +31,7 @@ public:
private:
std::shared_ptr<SHAMap> mMap;
bool mHaveRoot;
bool mHaveRoot{false};
std::unique_ptr<PeerSet> mPeerSet;
void

View File

@@ -146,23 +146,23 @@ public:
explicit Metrics() = default;
/// Number of transactions in the queue
std::size_t txCount;
std::size_t txCount{};
/// Max transactions currently allowed in queue
std::optional<std::size_t> txQMaxSize;
/// Number of transactions currently in the open ledger
std::size_t txInLedger;
std::size_t txInLedger{};
/// Number of transactions expected per ledger
std::size_t txPerLedger;
std::size_t txPerLedger{};
/// Reference transaction fee level
FeeLevel64 referenceFeeLevel;
FeeLevel64 referenceFeeLevel{};
/// Minimum fee level for a transaction to be considered for
/// the open ledger or the queue
FeeLevel64 minProcessingFeeLevel;
FeeLevel64 minProcessingFeeLevel{};
/// Median fee level of the last ledger
FeeLevel64 medFeeLevel;
FeeLevel64 medFeeLevel{};
/// Minimum fee level to get into the current open ledger,
/// bypassing the queue
FeeLevel64 openLedgerFeeLevel;
FeeLevel64 openLedgerFeeLevel{};
};
/**
@@ -511,7 +511,7 @@ private:
their `retriesRemaining` forced down as part of the
penalty.
*/
int retriesRemaining;
int retriesRemaining{retriesAllowed};
/// Flags provided to `apply`. If the transaction is later
/// attempted with different flags, it will need to be
/// `preflight`ed again.

View File

@@ -157,7 +157,7 @@ class ValidatorList
std::vector<PublicKey> list;
std::vector<std::string> manifests;
std::size_t sequence;
std::size_t sequence{};
TimeKeeper::time_point validFrom;
TimeKeeper::time_point validUntil;
std::string siteUri;
@@ -173,7 +173,7 @@ class ValidatorList
struct PublisherListCollection
{
PublisherStatus status;
PublisherStatus status = PublisherStatus::unavailable;
/*
The `current` VL is the one which
1. Has the largest sequence number that
@@ -223,7 +223,7 @@ class ValidatorList
hash_set<PublicKey> trustedMasterKeys_;
// Minimum number of lists on which a trusted validator must appear on
std::size_t listThreshold_;
std::size_t listThreshold_{1};
// The current list of trusted signing keys. For those validators using
// a manifest, the signing key is the ephemeral key. For the ones using

View File

@@ -85,12 +85,12 @@ private:
/// when we've gotten a temp redirect
std::shared_ptr<Resource> activeResource;
unsigned short redirCount;
unsigned short redirCount{0};
std::chrono::minutes refreshInterval;
clock_type::time_point nextRefresh;
std::optional<Status> lastRefreshStatus;
endpoint_type lastRequestEndpoint;
bool lastRequestSuccessful;
bool lastRequestSuccessful{false};
};
Application& app_;

View File

@@ -257,7 +257,6 @@ TxQ::MaybeTx::MaybeTx(
, account(txn_->getAccountID(sfAccount))
, lastValid(getLastLedgerSequence(*txn_))
, seqProxy(txn_->getSeqProxy())
, retriesRemaining(retriesAllowed)
, flags(flags_)
, pfResult(pfResult_)
{

View File

@@ -109,7 +109,7 @@ ValidatorList::ValidatorList(
, j_(j)
, quorum_(minimumQuorum.value_or(1)) // Genesis ledger quorum
, minimumQuorum_(minimumQuorum)
, listThreshold_(1)
{
}

View File

@@ -60,10 +60,9 @@ ValidatorSite::Site::Resource::Resource(std::string uri_) : uri{std::move(uri_)}
ValidatorSite::Site::Site(std::string uri)
: loadedResource{std::make_shared<Resource>(std::move(uri))}
, startingResource{loadedResource}
, redirCount{0}
, refreshInterval{default_refresh_interval}
, nextRefresh{clock_type::now()}
, lastRequestSuccessful{false}
{
}

View File

@@ -554,7 +554,7 @@ private:
ConsensusParms::AvalancheState closeTimeAvalancheState_ = ConsensusParms::init;
// Time it took for the last consensus round to converge
std::chrono::milliseconds prevRoundTime_;
std::chrono::milliseconds prevRoundTime_{};
//-------------------------------------------------------------------------
// Network time measurements of consensus progress

View File

@@ -117,7 +117,7 @@ class ConsensusTimer
{
using time_point = std::chrono::steady_clock::time_point;
time_point start_;
std::chrono::milliseconds dur_;
std::chrono::milliseconds dur_{};
public:
std::chrono::milliseconds

View File

@@ -39,7 +39,7 @@ public:
@param j Journal for debugging
*/
DisputedTx(Tx_t const& tx, bool ourVote, std::size_t numPeers, beast::Journal j)
: yays_(0), nays_(0), ourVote_(ourVote), tx_(tx), j_(j)
: ourVote_(ourVote), tx_(tx), j_(j)
{
votes_.reserve(numPeers);
}
@@ -173,8 +173,8 @@ public:
getJson() const;
private:
int yays_; //< Number of yes votes
int nays_; //< Number of no votes
int yays_{0}; //< Number of yes votes
int nays_{0}; //< Number of no votes
bool ourVote_; //< Our vote (true is yes)
Tx_t tx_; //< Transaction under dispute
Map_t votes_; //< Map from NodeID to vote
@@ -258,8 +258,8 @@ DisputedTx<Tx_t, NodeID_t>::updateVote(int percentTime, bool proposing, Consensu
if (!ourVote_ && (yays_ == 0))
return false;
bool newPosition;
int weight;
bool newPosition = false;
int weight = 0;
// When proposing, to prevent avalanche stalls, we increase the needed
// weight slightly over time. We also need to ensure that the consensus has

View File

@@ -72,7 +72,7 @@ public:
XRPL_ASSERT(ledger_.seq() == start_, "xrpl::Span::Span : ledger is genesis");
}
Span(Ledger ledger) : start_{0}, end_{ledger.seq() + Seq{1}}, ledger_{std::move(ledger)}
Span(Ledger ledger) : end_{ledger.seq() + Seq{1}}, ledger_{std::move(ledger)}
{
}

View File

@@ -98,9 +98,7 @@ private:
* validator message source
*/
Slot(SquelchHandler const& handler, beast::Journal journal, uint16_t maxSelectedPeers)
: reachedThreshold_(0)
, lastSelected_(clock_type::now())
, state_(SlotState::Counting)
: lastSelected_(clock_type::now())
, handler_(handler)
, journal_(journal)
, maxSelectedPeers_(maxSelectedPeers)
@@ -220,14 +218,14 @@ private:
std::unordered_set<id_t> considered_;
// number of peers that reached MAX_MESSAGE_THRESHOLD
std::uint16_t reachedThreshold_;
std::uint16_t reachedThreshold_{0};
// last time peers were selected, used to age the slot
typename clock_type::time_point lastSelected_;
SlotState state_; // slot's state
SquelchHandler const& handler_; // squelch/unsquelch handler
beast::Journal const journal_; // logging
SlotState state_{SlotState::Counting}; // slot's state
SquelchHandler const& handler_; // squelch/unsquelch handler
beast::Journal const journal_; // logging
// the maximum number of peers that should be selected as a validator
// message source

View File

@@ -145,7 +145,7 @@ public:
beast::Journal journal,
OverlayImpl& overlay);
~ConnectAttempt();
virtual ~ConnectAttempt();
/**
* @brief Stop the connection attempt

View File

@@ -126,7 +126,6 @@ OverlayImpl::OverlayImpl(
collector))
, m_resolver(resolver)
, next_id_(1)
, timer_count_(0)
, slots_(app, *this, app.config())
, m_stats(
std::bind(&OverlayImpl::collect_metrics, this),

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