diff --git a/.clang-tidy b/.clang-tidy index e67e7a4c6c..f18e7ec6d9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -108,30 +108,30 @@ Checks: "-*, performance-move-constructor-init, performance-no-automatic-move, performance-trivially-destructible, - # readability-avoid-nested-conditional-operator, # has issues - # readability-avoid-return-with-void-value, # has issues - # readability-braces-around-statements, # has issues - # readability-const-return-type, # has issues - # readability-container-contains, # has issues - # readability-container-size-empty, # has issues - # readability-convert-member-functions-to-static, # has issues + readability-avoid-nested-conditional-operator, + readability-avoid-return-with-void-value, + readability-braces-around-statements, + readability-const-return-type, + readability-container-contains, + readability-container-size-empty, + readability-convert-member-functions-to-static, readability-duplicate-include, - # readability-else-after-return, # has issues - # readability-enum-initial-value, # has issues - # readability-implicit-bool-conversion, # has issues - # readability-make-member-function-const, # has issues - # readability-math-missing-parentheses, # has issues + readability-else-after-return, + readability-enum-initial-value, + readability-implicit-bool-conversion, + readability-make-member-function-const, + readability-math-missing-parentheses, readability-misleading-indentation, readability-non-const-parameter, - # readability-redundant-casting, # has issues - # readability-redundant-declaration, # has issues - # readability-redundant-inline-specifier, # has issues - # readability-redundant-member-init, # has issues + readability-redundant-casting, + readability-redundant-declaration, + readability-redundant-inline-specifier, + readability-redundant-member-init, readability-redundant-string-init, readability-reference-to-constructed-temporary, - # readability-simplify-boolean-expr, # has issues - # readability-static-definition-in-anonymous-namespace, # has issues - # readability-suspicious-call-argument, # has issues + readability-simplify-boolean-expr, + readability-static-definition-in-anonymous-namespace, + readability-suspicious-call-argument, readability-use-std-min-max " # --- diff --git a/include/xrpl/basics/BasicConfig.h b/include/xrpl/basics/BasicConfig.h index f6fa5c52dc..84fb5335cd 100644 --- a/include/xrpl/basics/BasicConfig.h +++ b/include/xrpl/basics/BasicConfig.h @@ -67,9 +67,13 @@ public: legacy(std::string value) { if (lines_.empty()) + { lines_.emplace_back(std::move(value)); + } else + { lines_[0] = std::move(value); + } } /** @@ -84,8 +88,10 @@ public: if (lines_.empty()) return ""; if (lines_.size() > 1) + { Throw( "A legacy value must have exactly one line. Section: " + name_); + } return lines_[0]; } diff --git a/include/xrpl/basics/Buffer.h b/include/xrpl/basics/Buffer.h index 5192daf632..02926e9420 100644 --- a/include/xrpl/basics/Buffer.h +++ b/include/xrpl/basics/Buffer.h @@ -24,7 +24,8 @@ public: Buffer() = default; /** Create an uninitialized buffer with the given size. */ - explicit Buffer(std::size_t size) : p_(size ? new std::uint8_t[size] : nullptr), size_(size) + explicit Buffer(std::size_t size) + : p_((size != 0u) ? new std::uint8_t[size] : nullptr), size_(size) { } @@ -36,7 +37,7 @@ public: */ Buffer(void const* data, std::size_t size) : Buffer(size) { - if (size) + if (size != 0u) std::memcpy(p_.get(), data, size); } @@ -114,7 +115,7 @@ public: operator Slice() const noexcept { - if (!size_) + if (size_ == 0u) return Slice{}; return Slice{p_.get(), size_}; } @@ -155,7 +156,7 @@ public: { if (n != size_) { - p_.reset(n ? new std::uint8_t[n] : nullptr); + p_.reset((n != 0u) ? new std::uint8_t[n] : nullptr); size_ = n; } return p_.get(); @@ -199,7 +200,7 @@ operator==(Buffer const& lhs, Buffer const& rhs) noexcept if (lhs.size() != rhs.size()) return false; - if (lhs.size() == 0) + if (lhs.empty()) return true; return std::memcmp(lhs.data(), rhs.data(), lhs.size()) == 0; diff --git a/include/xrpl/basics/CompressionAlgorithms.h b/include/xrpl/basics/CompressionAlgorithms.h index c549a58b93..31525fa915 100644 --- a/include/xrpl/basics/CompressionAlgorithms.h +++ b/include/xrpl/basics/CompressionAlgorithms.h @@ -68,12 +68,15 @@ lz4Decompress( if (decompressedSize <= 0) Throw("lz4Decompress: integer overflow (output)"); + // NOLINTNEXTLINE(readability-suspicious-call-argument) if (LZ4_decompress_safe( reinterpret_cast(in), reinterpret_cast(decompressed), inSize, decompressedSize) != decompressedSize) + { Throw("lz4Decompress: failed"); + } return decompressedSize; } diff --git a/include/xrpl/basics/DecayingSample.h b/include/xrpl/basics/DecayingSample.h index d3343535e9..d4c7388046 100644 --- a/include/xrpl/basics/DecayingSample.h +++ b/include/xrpl/basics/DecayingSample.h @@ -67,7 +67,7 @@ private: } else { - while (elapsed--) + while ((elapsed--) != 0u) m_value -= (m_value + Window - 1) / Window; } } diff --git a/include/xrpl/basics/IntrusiveRefCounts.h b/include/xrpl/basics/IntrusiveRefCounts.h index 36616bc64f..ea610a521e 100644 --- a/include/xrpl/basics/IntrusiveRefCounts.h +++ b/include/xrpl/basics/IntrusiveRefCounts.h @@ -247,7 +247,7 @@ IntrusiveRefCounts::releaseStrongRef() const using enum ReleaseStrongRefAction; auto prevIntVal = refCounts.load(std::memory_order_acquire); - while (1) + while (true) { RefCountPair const prevVal{prevIntVal}; XRPL_ASSERT( @@ -298,7 +298,7 @@ IntrusiveRefCounts::addWeakReleaseStrongRef() const // Note: If this becomes a perf bottleneck, the `partialDestroyStartedMask` // may be able to be set non-atomically. But it is easier to reason about // the code if the flag is set atomically. - while (1) + while (true) { RefCountPair const prevVal{prevIntVal}; // Converted the last strong pointer to a weak pointer. @@ -343,7 +343,7 @@ IntrusiveRefCounts::releaseWeakRef() const RefCountPair prev = prevIntVal; if (prev.weak == 1 && prev.strong == 0) { - if (!prev.partialDestroyStartedBit) + if (prev.partialDestroyStartedBit == 0u) { // This case should only be hit if the partialDestroyStartedBit is // set non-atomically (and even then very rarely). The code is kept @@ -352,7 +352,7 @@ IntrusiveRefCounts::releaseWeakRef() const prevIntVal = refCounts.load(std::memory_order_acquire); prev = RefCountPair{prevIntVal}; } - if (!prev.partialDestroyFinishedBit) + if (prev.partialDestroyFinishedBit == 0u) { // partial destroy MUST finish before running a full destroy (when // using weak pointers) @@ -372,7 +372,7 @@ IntrusiveRefCounts::checkoutStrongRefFromWeak() const noexcept while (!refCounts.compare_exchange_weak(curValue, desiredValue, std::memory_order_acq_rel)) { RefCountPair const prev{curValue}; - if (!prev.strong) + if (prev.strong == 0u) return false; desiredValue = curValue + strongDelta; diff --git a/include/xrpl/basics/LocalValue.h b/include/xrpl/basics/LocalValue.h index 4ac76b130d..2e7bb73f6c 100644 --- a/include/xrpl/basics/LocalValue.h +++ b/include/xrpl/basics/LocalValue.h @@ -42,10 +42,10 @@ struct LocalValues // Keys are the address of a LocalValue. std::unordered_map> values; - static inline void + static void cleanup(LocalValues* lvs) { - if (lvs && !lvs->onCoro) + if ((lvs != nullptr) && !lvs->onCoro) delete lvs; } }; @@ -89,7 +89,7 @@ T& LocalValue::operator*() { auto lvs = detail::getLocalValues().get(); - if (!lvs) + if (lvs == nullptr) { lvs = new detail::LocalValues(); lvs->onCoro = false; diff --git a/include/xrpl/basics/Number.h b/include/xrpl/basics/Number.h index c39aae2dd3..51ade0b5ea 100644 --- a/include/xrpl/basics/Number.h +++ b/include/xrpl/basics/Number.h @@ -78,7 +78,7 @@ struct MantissaRange } rep min; - rep max{min * 10 - 1}; + rep max{(min * 10) - 1}; int log; mantissa_scale scale; @@ -342,7 +342,9 @@ public: constexpr int signum() const noexcept { - return negative_ ? -1 : (mantissa_ ? 1 : 0); + if (negative_) + return -1; + return (mantissa_ != 0u) ? 1 : 0; } Number @@ -402,19 +404,19 @@ public: static void setMantissaScale(MantissaRange::mantissa_scale scale); - inline static internalrep + static internalrep minMantissa() { return range_.get().min; } - inline static internalrep + static internalrep maxMantissa() { return range_.get().max; } - inline static int + static int mantissaLog() { return range_.get().log; @@ -507,16 +509,12 @@ private: class Guard; }; -inline constexpr Number::Number( - bool negative, - internalrep mantissa, - int exponent, - unchecked) noexcept +constexpr Number::Number(bool negative, internalrep mantissa, int exponent, unchecked) noexcept : negative_(negative), mantissa_{mantissa}, exponent_{exponent} { } -inline constexpr Number::Number(internalrep mantissa, int exponent, unchecked) noexcept +constexpr Number::Number(internalrep mantissa, int exponent, unchecked) noexcept : Number(false, mantissa, exponent, unchecked{}) { } @@ -548,7 +546,7 @@ inline Number::Number(rep mantissa) : Number{mantissa, 0} * Please see the "---- External Interface ----" section of the class * documentation for an explanation of why the internal value may be modified. */ -inline constexpr Number::rep +constexpr Number::rep Number::mantissa() const noexcept { auto m = mantissa_; @@ -569,7 +567,7 @@ Number::mantissa() const noexcept * Please see the "---- External Interface ----" section of the class * documentation for an explanation of why the internal value may be modified. */ -inline constexpr int +constexpr int Number::exponent() const noexcept { auto e = exponent_; @@ -584,13 +582,13 @@ Number::exponent() const noexcept return e; } -inline constexpr Number +constexpr Number Number::operator+() const noexcept { return *this; } -inline constexpr Number +constexpr Number Number::operator-() const noexcept { if (mantissa_ == 0) @@ -705,17 +703,19 @@ Number::normalizeToRange(T minMantissa, T maxMantissa) const int exponent = exponent_; if constexpr (std::is_unsigned_v) + { XRPL_ASSERT_PARTS( !negative, "xrpl::Number::normalizeToRange", "Number is non-negative for unsigned range."); + } Number::normalize(negative, mantissa, exponent, minMantissa, maxMantissa); auto const sign = negative ? -1 : 1; return std::make_pair(static_cast(sign * mantissa), exponent); } -inline constexpr Number +constexpr Number abs(Number x) noexcept { if (x < Number{}) @@ -746,7 +746,7 @@ power(Number const& f, unsigned n, unsigned d); // Return 0 if abs(x) < limit, else returns x -inline constexpr Number +constexpr Number squelch(Number const& x, Number const& limit) noexcept { if (abs(x) < limit) diff --git a/include/xrpl/basics/RangeSet.h b/include/xrpl/basics/RangeSet.h index f6e03cac79..4e54624056 100644 --- a/include/xrpl/basics/RangeSet.h +++ b/include/xrpl/basics/RangeSet.h @@ -117,22 +117,32 @@ from_string(RangeSet& rs, std::string const& s) case 1: { T front; if (!beast::lexicalCastChecked(front, intervals.front())) + { result = false; + } else + { rs.insert(front); + } break; } case 2: { T front; if (!beast::lexicalCastChecked(front, intervals.front())) + { result = false; + } else { T back; if (!beast::lexicalCastChecked(back, intervals.back())) + { result = false; + } else + { rs.insert(range(front, back)); + } } break; } diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index 90e64b58a2..e3fefa3dfb 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -98,7 +98,7 @@ class SlabAllocator ret = l_; - if (ret) + if (ret != nullptr) { // Use memcpy to avoid unaligned UB // (will optimize to equivalent code) @@ -159,7 +159,7 @@ public: std::size_t extra, std::size_t alloc = 0, std::size_t align = 0) - : itemAlignment_(align ? align : alignof(Type)) + : itemAlignment_((align != 0u) ? align : alignof(Type)) , itemSize_(boost::alignment::align_up(sizeof(Type) + extra, itemAlignment_)) , slabSize_(alloc) { @@ -215,7 +215,7 @@ public: // We want to allocate the memory at a 2 MiB boundary, to make it // possible to use hugepage mappings on Linux: auto buf = boost::alignment::aligned_alloc(megabytes(std::size_t(2)), size); - if (!buf) [[unlikely]] + if (buf == nullptr) [[unlikely]] return nullptr; #if BOOST_OS_LINUX @@ -235,7 +235,7 @@ public: // This operation is essentially guaranteed not to fail but // let's be careful anyways. - if (!boost::alignment::align(itemAlignment_, itemSize_, slabData, slabSize)) + if (boost::alignment::align(itemAlignment_, itemSize_, slabData, slabSize) == nullptr) { boost::alignment::aligned_free(buf); return nullptr; diff --git a/include/xrpl/basics/Slice.h b/include/xrpl/basics/Slice.h index 6aa5446236..bfcbb460f4 100644 --- a/include/xrpl/basics/Slice.h +++ b/include/xrpl/basics/Slice.h @@ -183,7 +183,7 @@ operator==(Slice const& lhs, Slice const& rhs) noexcept if (lhs.size() != rhs.size()) return false; - if (lhs.size() == 0) + if (lhs.empty()) return true; return std::memcmp(lhs.data(), rhs.data(), lhs.size()) == 0; diff --git a/include/xrpl/basics/algorithm.h b/include/xrpl/basics/algorithm.h index b3fdd5453d..9dae731a89 100644 --- a/include/xrpl/basics/algorithm.h +++ b/include/xrpl/basics/algorithm.h @@ -23,8 +23,10 @@ generalized_set_intersection( { while (first1 != last1 && first2 != last2) { - if (comp(*first1, *first2)) // if *first1 < *first2 - ++first1; // then reduce first range + if (comp(*first1, *first2)) + { // if *first1 < *first2 + ++first1; // then reduce first range + } else { if (!comp(*first2, *first1)) // if *first1 == *first2 diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index 5fb13319ea..6fe6bacf89 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -183,11 +183,17 @@ private: return ParseResult::badChar; if (c >= 'a') + { nibble = static_cast(c - 'a' + 0xA); + } else if (c >= 'A') + { nibble = static_cast(c - 'A' + 0xA); + } else if (c <= '9') + { nibble = static_cast(c - '0'); + } if (nibble > 0xFu) return ParseResult::badChar; @@ -308,8 +314,10 @@ public: signum() const { for (int i = 0; i < WIDTH; i++) + { if (data_[i] != 0) return 1; + } return 0; } @@ -390,7 +398,7 @@ public: return *this; } - base_uint const + base_uint operator++(int) { // postfix operator @@ -415,7 +423,7 @@ public: return *this; } - base_uint const + base_uint operator--(int) { // postfix operator @@ -444,7 +452,7 @@ public: { std::uint64_t carry = 0; - for (int i = WIDTH; i--;) + for (int i = WIDTH - 1; i >= 0; i--) { std::uint64_t const n = carry + boost::endian::big_to_native(data_[i]) + boost::endian::big_to_native(b.data_[i]); @@ -532,7 +540,7 @@ using uint256 = base_uint<256>; using uint192 = base_uint<192>; template -[[nodiscard]] inline constexpr std::strong_ordering +[[nodiscard]] constexpr std::strong_ordering operator<=>(base_uint const& lhs, base_uint const& rhs) { // This comparison might seem wrong on a casual inspection because it @@ -553,7 +561,7 @@ operator<=>(base_uint const& lhs, base_uint const& rhs) } template -[[nodiscard]] inline constexpr bool +[[nodiscard]] constexpr bool operator==(base_uint const& lhs, base_uint const& rhs) { return (lhs <=> rhs) == 0; @@ -561,7 +569,7 @@ operator==(base_uint const& lhs, base_uint const& rhs) //------------------------------------------------------------------------------ template -inline constexpr bool +constexpr bool operator==(base_uint const& a, std::uint64_t b) { return a == base_uint(b); @@ -569,28 +577,28 @@ operator==(base_uint const& a, std::uint64_t b) //------------------------------------------------------------------------------ template -inline constexpr base_uint +constexpr base_uint operator^(base_uint const& a, base_uint const& b) { return base_uint(a) ^= b; } template -inline constexpr base_uint +constexpr base_uint operator&(base_uint const& a, base_uint const& b) { return base_uint(a) &= b; } template -inline constexpr base_uint +constexpr base_uint operator|(base_uint const& a, base_uint const& b) { return base_uint(a) |= b; } template -inline constexpr base_uint +constexpr base_uint operator+(base_uint const& a, base_uint const& b) { return base_uint(a) += b; diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index f9e55d71a6..8af9341315 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -231,7 +231,8 @@ public: { // Set partitions to the number of hardware threads if the parameter // is either empty or set to 0. - partitions_ = partitions && *partitions ? *partitions : std::thread::hardware_concurrency(); + partitions_ = + partitions && (*partitions != 0u) ? *partitions : std::thread::hardware_concurrency(); map_.resize(partitions_); XRPL_ASSERT( partitions_, diff --git a/include/xrpl/basics/safe_cast.h b/include/xrpl/basics/safe_cast.h index 1e33b9663a..d85278b263 100644 --- a/include/xrpl/basics/safe_cast.h +++ b/include/xrpl/basics/safe_cast.h @@ -17,7 +17,7 @@ concept SafeToCast = (std::is_integral_v && std::is_integral_v) && : sizeof(Dest) >= sizeof(Src)); template -inline constexpr std::enable_if_t && std::is_integral_v, Dest> +constexpr std::enable_if_t && std::is_integral_v, Dest> safe_cast(Src s) noexcept { static_assert( @@ -30,14 +30,14 @@ safe_cast(Src s) noexcept } template -inline constexpr std::enable_if_t && std::is_integral_v, Dest> +constexpr std::enable_if_t && std::is_integral_v, Dest> safe_cast(Src s) noexcept { return static_cast(safe_cast>(s)); } template -inline constexpr std::enable_if_t && std::is_enum_v, Dest> +constexpr std::enable_if_t && std::is_enum_v, Dest> safe_cast(Src s) noexcept { return safe_cast(static_cast>(s)); @@ -48,7 +48,7 @@ safe_cast(Src s) noexcept // underlying types become safe, it can be converted to a safe_cast. template -inline constexpr std::enable_if_t && std::is_integral_v, Dest> +constexpr std::enable_if_t && std::is_integral_v, Dest> unsafe_cast(Src s) noexcept { static_assert( @@ -59,14 +59,14 @@ unsafe_cast(Src s) noexcept } template -inline constexpr std::enable_if_t && std::is_integral_v, Dest> +constexpr std::enable_if_t && std::is_integral_v, Dest> unsafe_cast(Src s) noexcept { return static_cast(unsafe_cast>(s)); } template -inline constexpr std::enable_if_t && std::is_enum_v, Dest> +constexpr std::enable_if_t && std::is_enum_v, Dest> unsafe_cast(Src s) noexcept { return unsafe_cast(static_cast>(s)); diff --git a/include/xrpl/beast/asio/io_latency_probe.h b/include/xrpl/beast/asio/io_latency_probe.h index 2dc1fcba15..9a8a63de4e 100644 --- a/include/xrpl/beast/asio/io_latency_probe.h +++ b/include/xrpl/beast/asio/io_latency_probe.h @@ -184,7 +184,7 @@ private: void operator()() const { - if (!m_probe) + if (m_probe == nullptr) return; typename Clock::time_point const now(Clock::now()); typename Clock::duration const elapsed(now - m_start); @@ -202,7 +202,7 @@ private: // Calculate when we want to sample again, and // adjust for the expected latency. // - typename Clock::time_point const when(now + m_probe->m_period - 2 * elapsed); + typename Clock::time_point const when(now + m_probe->m_period - (2 * elapsed)); if (when <= now) { @@ -224,7 +224,7 @@ private: void operator()(boost::system::error_code const& ec) { - if (!m_probe) + if (m_probe == nullptr) return; typename Clock::time_point const now(Clock::now()); boost::asio::post( diff --git a/include/xrpl/beast/container/detail/aged_container_iterator.h b/include/xrpl/beast/container/detail/aged_container_iterator.h index 99aab2a9a9..7a0e60bca8 100644 --- a/include/xrpl/beast/container/detail/aged_container_iterator.h +++ b/include/xrpl/beast/container/detail/aged_container_iterator.h @@ -16,10 +16,10 @@ class aged_container_iterator { public: using iterator_category = typename std::iterator_traits::iterator_category; - using value_type = typename std::conditional< + using value_type = std::conditional_t< is_const, typename Iterator::value_type::stashed::value_type const, - typename Iterator::value_type::stashed::value_type>::type; + typename Iterator::value_type::stashed::value_type>; using difference_type = typename std::iterator_traits::difference_type; using pointer = value_type*; using reference = value_type&; @@ -32,9 +32,9 @@ public: template < bool other_is_const, class OtherIterator, - class = typename std::enable_if< - (other_is_const == false || is_const == true) && - std::is_same::value == false>::type> + class = std::enable_if_t< + (!other_is_const || is_const) && + !static_cast(std::is_same_v)>> explicit aged_container_iterator( aged_container_iterator const& other) : m_iter(other.m_iter) @@ -42,9 +42,7 @@ public: } // Disable constructing a const_iterator from a non-const_iterator. - template < - bool other_is_const, - class = typename std::enable_if::type> + template > aged_container_iterator(aged_container_iterator const& other) : m_iter(other.m_iter) { @@ -53,8 +51,8 @@ public: // Disable assigning a const_iterator to a non-const iterator template auto - operator=(aged_container_iterator const& other) -> typename std:: - enable_if::type + operator=(aged_container_iterator const& other) + -> std::enable_if_t { m_iter = other.m_iter; return *this; diff --git a/include/xrpl/beast/core/SemanticVersion.h b/include/xrpl/beast/core/SemanticVersion.h index f839ef8c53..244783234c 100644 --- a/include/xrpl/beast/core/SemanticVersion.h +++ b/include/xrpl/beast/core/SemanticVersion.h @@ -40,12 +40,12 @@ public: std::string print() const; - inline bool + bool isRelease() const noexcept { return preReleaseIdentifiers.empty(); } - inline bool + bool isPreRelease() const noexcept { return !isRelease(); diff --git a/include/xrpl/beast/hash/xxhasher.h b/include/xrpl/beast/hash/xxhasher.h index 7c6ae894fc..f89b15314a 100644 --- a/include/xrpl/beast/hash/xxhasher.h +++ b/include/xrpl/beast/hash/xxhasher.h @@ -64,7 +64,7 @@ private: void flushToState(void const* data, std::size_t len) { - if (!state_) + if (state_ == nullptr) { state_ = allocState(); if (seed_.has_value()) @@ -78,7 +78,7 @@ private: } XXH3_64bits_update(state_, readBuffer_.data(), readBuffer_.size()); resetBuffers(); - if (data && len) + if ((data != nullptr) && (len != 0u)) { XXH3_64bits_update(state_, data, len); } @@ -87,22 +87,18 @@ private: result_type retrieveHash() { - if (state_) + if (state_ != nullptr) { flushToState(nullptr, 0); return XXH3_64bits_digest(state_); } - else + + if (seed_.has_value()) { - if (seed_.has_value()) - { - return XXH3_64bits_withSeed(readBuffer_.data(), readBuffer_.size(), *seed_); - } - else - { - return XXH3_64bits(readBuffer_.data(), readBuffer_.size()); - } + return XXH3_64bits_withSeed(readBuffer_.data(), readBuffer_.size(), *seed_); } + + return XXH3_64bits(readBuffer_.data(), readBuffer_.size()); } public: @@ -119,7 +115,7 @@ public: ~xxhasher() noexcept { - if (state_) + if (state_ != nullptr) { XXH3_freeState(state_); } diff --git a/include/xrpl/beast/net/IPAddress.h b/include/xrpl/beast/net/IPAddress.h index 2ac4c3bc43..277a43e5d8 100644 --- a/include/xrpl/beast/net/IPAddress.h +++ b/include/xrpl/beast/net/IPAddress.h @@ -70,9 +70,13 @@ hash_append(Hasher& h, beast::IP::Address const& addr) noexcept { using beast::hash_append; if (addr.is_v4()) + { hash_append(h, addr.to_v4().to_bytes()); + } else if (addr.is_v6()) + { hash_append(h, addr.to_v6().to_bytes()); + } else { // LCOV_EXCL_START diff --git a/include/xrpl/beast/net/IPEndpoint.h b/include/xrpl/beast/net/IPEndpoint.h index 7a0394cbd1..5cb97f7afe 100644 --- a/include/xrpl/beast/net/IPEndpoint.h +++ b/include/xrpl/beast/net/IPEndpoint.h @@ -69,12 +69,12 @@ public: { return m_addr.is_v6(); } - AddressV4 const + AddressV4 to_v4() const { return m_addr.to_v4(); } - AddressV6 const + AddressV6 to_v6() const { return m_addr.to_v6(); diff --git a/include/xrpl/beast/rfc2616.h b/include/xrpl/beast/rfc2616.h index f43060eb20..08d49eb26c 100644 --- a/include/xrpl/beast/rfc2616.h +++ b/include/xrpl/beast/rfc2616.h @@ -350,8 +350,10 @@ bool token_in_list(boost::string_ref const& value, boost::string_ref const& token) { for (auto const& item : make_list(value)) + { if (ci_equal(item, token)) return true; + } return false; } @@ -360,8 +362,10 @@ bool is_keep_alive(boost::beast::http::message const& m) { if (m.version() <= 10) + { return boost::beast::http::token_list{m[boost::beast::http::field::connection]}.exists( "keep-alive"); + } return !boost::beast::http::token_list{m[boost::beast::http::field::connection]}.exists( "close"); } diff --git a/include/xrpl/beast/test/yield_to.h b/include/xrpl/beast/test/yield_to.h index 918ca3c0cc..07c1ef0799 100644 --- a/include/xrpl/beast/test/yield_to.h +++ b/include/xrpl/beast/test/yield_to.h @@ -44,7 +44,7 @@ public: : work_(boost::asio::make_work_guard(ios_)) { threads_.reserve(concurrency); - while (concurrency--) + while ((concurrency--) != 0u) threads_.emplace_back([&] { ios_.run(); }); } diff --git a/include/xrpl/beast/type_name.h b/include/xrpl/beast/type_name.h index 99b90d1757..600f530adc 100644 --- a/include/xrpl/beast/type_name.h +++ b/include/xrpl/beast/type_name.h @@ -32,9 +32,13 @@ type_name() if (std::is_volatile::value) name += " volatile"; if (std::is_lvalue_reference::value) + { name += "&"; + } else if (std::is_rvalue_reference::value) + { name += "&&"; + } return name; } diff --git a/include/xrpl/beast/unit_test/recorder.h b/include/xrpl/beast/unit_test/recorder.h index 8f956fda88..0b3fc34787 100644 --- a/include/xrpl/beast/unit_test/recorder.h +++ b/include/xrpl/beast/unit_test/recorder.h @@ -50,7 +50,7 @@ private: virtual void on_case_end() override { - if (m_case.tests.size() > 0) + if (!m_case.tests.empty()) m_suite.insert(std::move(m_case)); } diff --git a/include/xrpl/beast/unit_test/runner.h b/include/xrpl/beast/unit_test/runner.h index c8a6956732..7b93d8ad56 100644 --- a/include/xrpl/beast/unit_test/runner.h +++ b/include/xrpl/beast/unit_test/runner.h @@ -198,8 +198,10 @@ runner::run_if(FwdIter first, FwdIter last, Pred pred) { bool failed(false); for (; first != last; ++first) + { if (pred(*first)) failed = run(*first) || failed; + } return failed; } @@ -219,8 +221,10 @@ runner::run_each_if(SequenceContainer const& c, Pred pred) { bool failed(false); for (auto const& s : c) + { if (pred(s)) failed = run(s) || failed; + } return failed; } diff --git a/include/xrpl/beast/unit_test/suite.h b/include/xrpl/beast/unit_test/suite.h index 2f0b69b8a0..33e9f462d9 100644 --- a/include/xrpl/beast/unit_test/suite.h +++ b/include/xrpl/beast/unit_test/suite.h @@ -309,7 +309,7 @@ private: run() = 0; void - propagate_abort(); + propagate_abort() const; template void @@ -486,9 +486,13 @@ suite::unexpected(Condition shouldBeFalse, String const& reason) { bool const b = static_cast(shouldBeFalse); if (!b) + { pass(); + } else + { fail(reason); + } return !b; } @@ -522,7 +526,7 @@ suite::fail(String const& reason, char const* file, int line) } inline void -suite::propagate_abort() +suite::propagate_abort() const { if (abort_ && aborted_) BOOST_THROW_EXCEPTION(abort_exception()); diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index 2ac5050b2d..0d293fc656 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -13,13 +13,13 @@ enum Severity { kAll = 0, kTrace = kAll, - kDebug, - kInfo, - kWarning, - kError, - kFatal, + kDebug = 1, + kInfo = 2, + kWarning = 3, + kError = 4, + kFatal = 5, - kDisabled, + kDisabled = 6, kNone = kDisabled }; } // namespace severities @@ -109,12 +109,12 @@ public: }; #ifndef __INTELLISENSE__ - static_assert(std::is_default_constructible::value == false, ""); - static_assert(std::is_copy_constructible::value == false, ""); - static_assert(std::is_move_constructible::value == false, ""); - static_assert(std::is_copy_assignable::value == false, ""); - static_assert(std::is_move_assignable::value == false, ""); - static_assert(std::is_nothrow_destructible::value == true, ""); + static_assert(!std::is_default_constructible_v, ""); + static_assert(!std::is_copy_constructible_v, ""); + static_assert(!std::is_move_constructible_v, ""); + static_assert(!std::is_copy_assignable_v, ""); + static_assert(!std::is_move_assignable_v, ""); + static_assert(std::is_nothrow_destructible_v, ""); #endif /** Returns a Sink which does nothing. */ @@ -165,12 +165,12 @@ public: }; #ifndef __INTELLISENSE__ - static_assert(std::is_default_constructible::value == false, ""); - static_assert(std::is_copy_constructible::value == true, ""); - static_assert(std::is_move_constructible::value == true, ""); - static_assert(std::is_copy_assignable::value == false, ""); - static_assert(std::is_move_assignable::value == false, ""); - static_assert(std::is_nothrow_destructible::value == true, ""); + static_assert(!std::is_default_constructible_v, ""); + static_assert(std::is_copy_constructible_v, ""); + static_assert(std::is_move_constructible_v, ""); + static_assert(!std::is_copy_assignable_v, ""); + static_assert(!std::is_move_assignable_v, ""); + static_assert(std::is_nothrow_destructible_v, ""); #endif //-------------------------------------------------------------------------- @@ -247,12 +247,12 @@ public: }; #ifndef __INTELLISENSE__ - static_assert(std::is_default_constructible::value == true, ""); - static_assert(std::is_copy_constructible::value == true, ""); - static_assert(std::is_move_constructible::value == true, ""); - static_assert(std::is_copy_assignable::value == false, ""); - static_assert(std::is_move_assignable::value == false, ""); - static_assert(std::is_nothrow_destructible::value == true, ""); + static_assert(std::is_default_constructible_v, ""); + static_assert(std::is_copy_constructible_v, ""); + static_assert(std::is_move_constructible_v, ""); + static_assert(!std::is_copy_assignable_v, ""); + static_assert(!std::is_move_assignable_v, ""); + static_assert(std::is_nothrow_destructible_v, ""); #endif //-------------------------------------------------------------------------- @@ -330,12 +330,12 @@ public: }; #ifndef __INTELLISENSE__ -static_assert(std::is_default_constructible::value == false, ""); -static_assert(std::is_copy_constructible::value == true, ""); -static_assert(std::is_move_constructible::value == true, ""); -static_assert(std::is_copy_assignable::value == true, ""); -static_assert(std::is_move_assignable::value == true, ""); -static_assert(std::is_nothrow_destructible::value == true, ""); +static_assert(!std::is_default_constructible_v, ""); +static_assert(std::is_copy_constructible_v, ""); +static_assert(std::is_move_constructible_v, ""); +static_assert(std::is_copy_assignable_v, ""); +static_assert(std::is_move_assignable_v, ""); +static_assert(std::is_nothrow_destructible_v, ""); #endif //------------------------------------------------------------------------------ diff --git a/include/xrpl/beast/utility/Zero.h b/include/xrpl/beast/utility/Zero.h index 3b50b3fe00..872a78e97f 100644 --- a/include/xrpl/beast/utility/Zero.h +++ b/include/xrpl/beast/utility/Zero.h @@ -27,7 +27,7 @@ struct Zero }; namespace { -static constexpr Zero zero{}; +constexpr Zero zero{}; } // namespace /** Default implementation of signum calls the method on the class. */ diff --git a/include/xrpl/conditions/detail/utils.h b/include/xrpl/conditions/detail/utils.h index 17d93d43b5..2a0ef92ab3 100644 --- a/include/xrpl/conditions/detail/utils.h +++ b/include/xrpl/conditions/detail/utils.h @@ -89,7 +89,7 @@ parsePreamble(Slice& s, std::error_code& ec) p.length = s[0]; s += 1; - if (p.length & 0x80) + if ((p.length & 0x80) != 0u) { // Long form length: std::size_t const cnt = p.length & 0x7F; diff --git a/include/xrpl/core/ClosureCounter.h b/include/xrpl/core/ClosureCounter.h index b1939b2e63..730cc12dfe 100644 --- a/include/xrpl/core/ClosureCounter.h +++ b/include/xrpl/core/ClosureCounter.h @@ -34,9 +34,9 @@ template class ClosureCounter { private: - std::mutex mutable mutex_{}; - std::condition_variable allClosuresDoneCond_{}; // guard with mutex_ - bool waitForClosures_{false}; // guard with mutex_ + std::mutex mutable mutex_; + std::condition_variable allClosuresDoneCond_; // guard with mutex_ + bool waitForClosures_{false}; // guard with mutex_ std::atomic closureCount_{0}; // Increment the count. diff --git a/include/xrpl/core/PeerReservationTable.h b/include/xrpl/core/PeerReservationTable.h index fc943f0807..3fb85e392f 100644 --- a/include/xrpl/core/PeerReservationTable.h +++ b/include/xrpl/core/PeerReservationTable.h @@ -20,7 +20,7 @@ struct PeerReservation final { public: PublicKey nodeId; - std::string description{}; + std::string description = {}; // NOLINT(readability-redundant-member-init) auto toJson() const -> Json::Value; @@ -68,7 +68,7 @@ public: contains(PublicKey const& nodeId) { std::lock_guard const lock(this->mutex_); - return table_.find({nodeId}) != table_.end(); + return table_.contains({.nodeId = nodeId, .description = {}}); } // Because `ApplicationImp` has two-phase initialization, so must we. diff --git a/include/xrpl/json/to_string.h b/include/xrpl/json/to_string.h index fb379f5759..c9820e2e55 100644 --- a/include/xrpl/json/to_string.h +++ b/include/xrpl/json/to_string.h @@ -1,12 +1,11 @@ #pragma once -#include +#include + #include namespace Json { -class Value; - /** Writes a Json::Value to an std::string. */ std::string to_string(Value const&); @@ -15,8 +14,4 @@ to_string(Value const&); std::string pretty(Value const&); -/** Output using the StyledStreamWriter. @see Json::operator>>(). */ -std::ostream& -operator<<(std::ostream&, Value const& root); - } // namespace Json diff --git a/include/xrpl/ledger/AmendmentTable.h b/include/xrpl/ledger/AmendmentTable.h index 6ecfe2a240..7fd8efadf1 100644 --- a/include/xrpl/ledger/AmendmentTable.h +++ b/include/xrpl/ledger/AmendmentTable.h @@ -75,10 +75,12 @@ public: doValidatedLedger(std::shared_ptr const& lastValidatedLedger) { if (needValidatedLedger(lastValidatedLedger->seq())) + { doValidatedLedger( lastValidatedLedger->seq(), getEnabledAmendments(*lastValidatedLedger), getMajorityAmendments(*lastValidatedLedger)); + } } /** Called to determine whether the amendment logic needs to process diff --git a/include/xrpl/ledger/CanonicalTXSet.h b/include/xrpl/ledger/CanonicalTXSet.h index 45f58b5701..857b82a734 100644 --- a/include/xrpl/ledger/CanonicalTXSet.h +++ b/include/xrpl/ledger/CanonicalTXSet.h @@ -29,31 +29,31 @@ private: friend bool operator<(Key const& lhs, Key const& rhs); - inline friend bool + friend bool operator>(Key const& lhs, Key const& rhs) { return rhs < lhs; } - inline friend bool + friend bool operator<=(Key const& lhs, Key const& rhs) { return !(lhs > rhs); } - inline friend bool + friend bool operator>=(Key const& lhs, Key const& rhs) { return !(lhs < rhs); } - inline friend bool + friend bool operator==(Key const& lhs, Key const& rhs) { return lhs.txId_ == rhs.txId_; } - inline friend bool + friend bool operator!=(Key const& lhs, Key const& rhs) { return !(lhs == rhs); diff --git a/include/xrpl/ledger/PendingSaves.h b/include/xrpl/ledger/PendingSaves.h index 4e952547da..ff70d48bb9 100644 --- a/include/xrpl/ledger/PendingSaves.h +++ b/include/xrpl/ledger/PendingSaves.h @@ -65,7 +65,7 @@ public: pending(LedgerIndex seq) { std::lock_guard const lock(mutex_); - return map_.find(seq) != map_.end(); + return map_.contains(seq); } /** Check if a ledger should be dispatched diff --git a/include/xrpl/ledger/helpers/AMMHelpers.h b/include/xrpl/ledger/helpers/AMMHelpers.h index 34597b3cb5..d261f9e018 100644 --- a/include/xrpl/ledger/helpers/AMMHelpers.h +++ b/include/xrpl/ledger/helpers/AMMHelpers.h @@ -208,10 +208,10 @@ getAMMOfferStartWithTakerGets( // Try to reduce the offer size to improve the quality. // The quality might still not match the targetQuality for a tiny offer. - if (auto amounts = getAmounts(*nTakerGets); Quality{amounts} < targetQuality) + auto amounts = getAmounts(*nTakerGets); + if (Quality{amounts} < targetQuality) return getAmounts(detail::reduceOffer(amounts.out)); - else - return amounts; + return amounts; } /** Generate AMM offer starting with takerPays when AMM pool @@ -275,10 +275,10 @@ getAMMOfferStartWithTakerPays( // Try to reduce the offer size to improve the quality. // The quality might still not match the targetQuality for a tiny offer. - if (auto amounts = getAmounts(*nTakerPays); Quality{amounts} < targetQuality) + auto amounts = getAmounts(*nTakerPays); + if (Quality{amounts} < targetQuality) return getAmounts(detail::reduceOffer(amounts.in)); - else - return amounts; + return amounts; } /** Generate AMM offer so that either updated Spot Price Quality (SPQ) @@ -318,9 +318,12 @@ changeSpotPriceQuality( auto const& a = f; auto const b = pool.in * (1 + f); Number const c = pool.in * pool.in - pool.in * pool.out * quality.rate(); - if (auto const res = b * b - 4 * a * c; res < 0) + auto const res = b * b - 4 * a * c; + if (res < 0) + { return std::nullopt; // LCOV_EXCL_LINE - else if (auto const nTakerPaysPropose = (-b + root2(res)) / (2 * a); nTakerPaysPropose > 0) + } + if (auto const nTakerPaysPropose = (-b + root2(res)) / (2 * a); nTakerPaysPropose > 0) { auto const nTakerPays = [&]() { // The fee might make the AMM offer quality less than CLOB @@ -465,13 +468,11 @@ swapAssetIn(TAmounts const& pool, TIn const& assetIn, std::uint16_t t return toAmount(getAsset(pool.out), swapOut, Number::downward); } - else - { - return toAmount( - getAsset(pool.out), - pool.out - (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), - Number::downward); - } + + return toAmount( + getAsset(pool.out), + pool.out - (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), + Number::downward); } /** Swap assetOut out of the pool and swap in a proportional amount @@ -533,13 +534,11 @@ swapAssetOut(TAmounts const& pool, TOut const& assetOut, std::uint16_ return toAmount(getAsset(pool.in), swapIn, Number::upward); } - else - { - return toAmount( - getAsset(pool.in), - ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / feeMult(tfee), - Number::upward); - } + + return toAmount( + getAsset(pool.in), + ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / feeMult(tfee), + Number::upward); } /** Return square of n. @@ -623,9 +622,13 @@ getRoundedAsset(Rules const& rules, STAmount const& balance, A const& frac, IsDe if (!rules.enabled(fixAMMv1_3)) { if constexpr (std::is_same_v) + { return multiply(balance, frac, balance.asset()); + } else + { return toSTAmount(balance.asset(), balance * frac); + } } auto const rm = detail::getAssetRounding(isDeposit); return multiply(balance, frac, rm); diff --git a/include/xrpl/ledger/helpers/DirectoryHelpers.h b/include/xrpl/ledger/helpers/DirectoryHelpers.h index 189dfcd263..2ae188182d 100644 --- a/include/xrpl/ledger/helpers/DirectoryHelpers.h +++ b/include/xrpl/ledger/helpers/DirectoryHelpers.h @@ -189,7 +189,7 @@ forEachItem( AccountID const& id, std::function const&)> const& f) { - return forEachItem(view, keylet::ownerDir(id), f); + forEachItem(view, keylet::ownerDir(id), f); } /** Iterate all items after an item in an owner directory. diff --git a/include/xrpl/net/AutoSocket.h b/include/xrpl/net/AutoSocket.h index 1c24e07f05..45e4919b8a 100644 --- a/include/xrpl/net/AutoSocket.h +++ b/include/xrpl/net/AutoSocket.h @@ -44,7 +44,7 @@ public: } bool - isSecure() + isSecure() const { return mSecure; } @@ -126,7 +126,9 @@ public: async_shutdown(ShutdownHandler handler) { if (isSecure()) + { mSocket->async_shutdown(handler); + } else { error_code ec; @@ -147,9 +149,13 @@ public: async_read_some(Seq const& buffers, Handler handler) { if (isSecure()) + { mSocket->async_read_some(buffers, handler); + } else + { PlainSocket().async_read_some(buffers, handler); + } } template @@ -157,9 +163,13 @@ public: async_read_until(Seq const& buffers, Condition condition, Handler handler) { if (isSecure()) + { boost::asio::async_read_until(*mSocket, buffers, condition, handler); + } else + { boost::asio::async_read_until(PlainSocket(), buffers, condition, handler); + } } template @@ -170,9 +180,13 @@ public: Handler handler) { if (isSecure()) + { boost::asio::async_read_until(*mSocket, buffers, delim, handler); + } else + { boost::asio::async_read_until(PlainSocket(), buffers, delim, handler); + } } template @@ -183,9 +197,13 @@ public: Handler handler) { if (isSecure()) + { boost::asio::async_read_until(*mSocket, buffers, cond, handler); + } else + { boost::asio::async_read_until(PlainSocket(), buffers, cond, handler); + } } template @@ -193,9 +211,13 @@ public: async_write(Buf const& buffers, Handler handler) { if (isSecure()) + { boost::asio::async_write(*mSocket, buffers, handler); + } else + { boost::asio::async_write(PlainSocket(), buffers, handler); + } } template @@ -203,9 +225,13 @@ public: async_write(boost::asio::basic_streambuf& buffers, Handler handler) { if (isSecure()) + { boost::asio::async_write(*mSocket, buffers, handler); + } else + { boost::asio::async_write(PlainSocket(), buffers, handler); + } } template @@ -213,9 +239,13 @@ public: async_read(Buf const& buffers, Condition cond, Handler handler) { if (isSecure()) + { boost::asio::async_read(*mSocket, buffers, cond, handler); + } else + { boost::asio::async_read(PlainSocket(), buffers, cond, handler); + } } template @@ -223,9 +253,13 @@ public: async_read(boost::asio::basic_streambuf& buffers, Condition cond, Handler handler) { if (isSecure()) + { boost::asio::async_read(*mSocket, buffers, cond, handler); + } else + { boost::asio::async_read(PlainSocket(), buffers, cond, handler); + } } template @@ -233,9 +267,13 @@ public: async_read(Buf const& buffers, Handler handler) { if (isSecure()) + { boost::asio::async_read(*mSocket, buffers, handler); + } else + { boost::asio::async_read(PlainSocket(), buffers, handler); + } } template @@ -243,9 +281,13 @@ public: async_write_some(Seq const& buffers, Handler handler) { if (isSecure()) + { mSocket->async_write_some(buffers, handler); + } else + { PlainSocket().async_write_some(buffers, handler); + } } protected: diff --git a/include/xrpl/net/HTTPClientSSLContext.h b/include/xrpl/net/HTTPClientSSLContext.h index 80e5835f5e..a53ecff849 100644 --- a/include/xrpl/net/HTTPClientSSLContext.h +++ b/include/xrpl/net/HTTPClientSSLContext.h @@ -30,8 +30,10 @@ public: registerSSLCerts(ssl_context_, ec, j_); if (ec && sslVerifyDir.empty()) + { Throw(boost::str( boost::format("Failed to set_default_verify_paths: %s") % ec.message())); + } } else { @@ -43,8 +45,10 @@ public: ssl_context_.add_verify_path(sslVerifyDir, ec); if (ec) + { Throw( boost::str(boost::format("Failed to add verify path: %s") % ec.message())); + } } } diff --git a/include/xrpl/nodestore/Types.h b/include/xrpl/nodestore/Types.h index 5adbc40f70..f44332a049 100644 --- a/include/xrpl/nodestore/Types.h +++ b/include/xrpl/nodestore/Types.h @@ -22,11 +22,11 @@ enum { /** Return codes from Backend operations. */ enum Status { - ok, - notFound, - dataCorrupt, - unknown, - backendError, + ok = 0, + notFound = 1, + dataCorrupt = 2, + unknown = 3, + backendError = 4, customCode = 100 }; diff --git a/include/xrpl/nodestore/detail/codec.h b/include/xrpl/nodestore/detail/codec.h index 4e12c6b4db..8096048185 100644 --- a/include/xrpl/nodestore/detail/codec.h +++ b/include/xrpl/nodestore/detail/codec.h @@ -113,9 +113,11 @@ nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf) { auto const hs = field::size; // Mask if (in_size < hs + 32) + { Throw( "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 = 0; read(is, mask); // Mask @@ -136,10 +138,12 @@ nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf) if (mask & bit) { if (in_size < 32) + { Throw( "nodeobject codec v1: short inner node subsize: " + std::string("in_size = ") + std::to_string(in_size) + " i = " + std::to_string(i)); + } std::memcpy(os.data(32), is(32), 32); in_size -= 32; } @@ -149,16 +153,20 @@ nodeobject_decompress(void const* in, std::size_t in_size, BufferFactory&& bf) } } if (in_size > 0) + { Throw( "nodeobject codec v1: long inner node, in_size = " + std::to_string(in_size)); + } break; } case 3: // full v1 inner node { - if (in_size != 16 * 32) // hashes + if (in_size != 16 * 32) + { // hashes Throw( "nodeobject codec v1: short full inner node, in_size = " + std::to_string(in_size)); + } istream is(p, in_size); result.second = 525; void* const out = bf(result.second); @@ -214,7 +222,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) void const* const h = is(32); if (std::memcmp(h, zero32(), 32) == 0) continue; - std::memcpy(vh.data() + 32 * n, h, 32); + std::memcpy(vh.data() + (32 * n), h, 32); mask |= bit; ++n; } @@ -225,7 +233,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) auto const type = 2U; auto const vs = size_varint(type); result.second = vs + field::size + // mask - n * 32; // hashes + (n * 32); // hashes std::uint8_t* out = reinterpret_cast(bf(result.second)); result.first = out; ostream os(out, result.second); @@ -237,7 +245,7 @@ nodeobject_compress(void const* in, std::size_t in_size, BufferFactory&& bf) // 3 = full v1 inner node auto const type = 3U; auto const vs = size_varint(type); - result.second = vs + n * 32; // hashes + result.second = vs + (n * 32); // hashes std::uint8_t* out = reinterpret_cast(bf(result.second)); result.first = out; ostream os(out, result.second); diff --git a/include/xrpl/nodestore/detail/varint.h b/include/xrpl/nodestore/detail/varint.h index c84ed383ed..cc7e49fd6f 100644 --- a/include/xrpl/nodestore/detail/varint.h +++ b/include/xrpl/nodestore/detail/varint.h @@ -42,8 +42,10 @@ read_varint(void const* buf, std::size_t buflen, std::size_t& t) std::uint8_t const* p = reinterpret_cast(buf); std::size_t n = 0; while (p[n] & 0x80) + { if (++n >= buflen) return 0; + } if (++n > buflen) return 0; // Special case for 0 diff --git a/include/xrpl/protocol/AmountConversions.h b/include/xrpl/protocol/AmountConversions.h index e1965c1d5c..9fb45e7bf8 100644 --- a/include/xrpl/protocol/AmountConversions.h +++ b/include/xrpl/protocol/AmountConversions.h @@ -148,11 +148,17 @@ toAmount(Asset const& asset, Number const& n, Number::rounding_mode mode = Numbe Number::setround(mode); if constexpr (std::is_same_v) + { return IOUAmount(n); + } else if constexpr (std::is_same_v) + { return XRPAmount(static_cast(n)); + } else if constexpr (std::is_same_v) + { return MPTAmount(static_cast(n)); + } else if constexpr (std::is_same_v) { if (isXRP(asset)) @@ -171,11 +177,17 @@ T toMaxAmount(Asset const& asset) { if constexpr (std::is_same_v) + { return IOUAmount(STAmount::cMaxValue, STAmount::cMaxOffset); + } else if constexpr (std::is_same_v) + { return XRPAmount(static_cast(STAmount::cMaxNativeN)); + } else if constexpr (std::is_same_v) + { return MPTAmount(maxMPTokenAmount); + } else if constexpr (std::is_same_v) { return asset.visit( @@ -204,13 +216,21 @@ Asset getAsset(T const& amt) { if constexpr (std::is_same_v) + { return noIssue(); + } else if constexpr (std::is_same_v) + { return xrpIssue(); + } else if constexpr (std::is_same_v) + { return noMPT(); + } else if constexpr (std::is_same_v) + { return amt.asset(); + } else { constexpr bool alwaysFalse = !std::is_same_v; @@ -223,13 +243,21 @@ constexpr T get(STAmount const& a) { if constexpr (std::is_same_v) + { return a.iou(); + } else if constexpr (std::is_same_v) + { return a.xrp(); + } else if constexpr (std::is_same_v) + { return a.mpt(); + } else if constexpr (std::is_same_v) + { return a; + } else { constexpr bool alwaysFalse = !std::is_same_v; diff --git a/include/xrpl/protocol/Asset.h b/include/xrpl/protocol/Asset.h index c8c629ab48..b1f0338665 100644 --- a/include/xrpl/protocol/Asset.h +++ b/include/xrpl/protocol/Asset.h @@ -221,9 +221,13 @@ operator==(Asset const& lhs, Asset const& rhs) return std::visit( [&](TLhs const& issLhs, TRhs const& issRhs) { if constexpr (std::is_same_v) + { return issLhs == issRhs; + } else + { return false; + } }, lhs.issue_, rhs.issue_); @@ -235,11 +239,17 @@ operator<=>(Asset const& lhs, Asset const& rhs) return std::visit( [](TLhs const& lhs_, TRhs const& rhs_) { if constexpr (std::is_same_v) + { return std::weak_ordering(lhs_ <=> rhs_); + } else if constexpr (is_issue_v && is_mptissue_v) + { return std::weak_ordering::greater; + } else + { return std::weak_ordering::less; + } }, lhs.issue_, rhs.issue_); @@ -267,11 +277,17 @@ equalTokens(Asset const& lhs, Asset const& rhs) return std::visit( [&](TLhs const& issLhs, TRhs const& issRhs) { if constexpr (std::is_same_v && std::is_same_v) + { return issLhs.currency == issRhs.currency; + } else if constexpr (std::is_same_v && std::is_same_v) + { return issLhs.getMptID() == issRhs.getMptID(); + } else + { return false; + } }, lhs.issue_, rhs.issue_); @@ -292,9 +308,6 @@ validJSONAsset(Json::Value const& jv); Asset assetFromJson(Json::Value const& jv); -Json::Value -to_json(Asset const& asset); - inline bool isConsistent(Asset const& asset) { diff --git a/include/xrpl/protocol/Book.h b/include/xrpl/protocol/Book.h index 638d9b387d..36bf708f05 100644 --- a/include/xrpl/protocol/Book.h +++ b/include/xrpl/protocol/Book.h @@ -53,7 +53,7 @@ reversed(Book const& book); /** Equality comparison. */ /** @{ */ -[[nodiscard]] inline constexpr bool +[[nodiscard]] constexpr bool operator==(Book const& lhs, Book const& rhs) { return (lhs.in == rhs.in) && (lhs.out == rhs.out) && (lhs.domain == rhs.domain); @@ -62,7 +62,7 @@ operator==(Book const& lhs, Book const& rhs) /** Strict weak ordering. */ /** @{ */ -[[nodiscard]] inline constexpr std::weak_ordering +[[nodiscard]] constexpr std::weak_ordering operator<=>(Book const& lhs, Book const& rhs) { if (auto const c{lhs.in <=> rhs.in}; c != 0) diff --git a/include/xrpl/protocol/Feature.h b/include/xrpl/protocol/Feature.h index cbd41b84f8..8f96935ca1 100644 --- a/include/xrpl/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -107,8 +107,8 @@ validFeatureName(auto fn) -> bool return true; } -enum class VoteBehavior : int { Obsolete = -1, DefaultNo = 0, DefaultYes }; -enum class AmendmentSupport : int { Retired = -1, Supported = 0, Unsupported }; +enum class VoteBehavior : int { Obsolete = -1, DefaultNo = 0, DefaultYes = 1 }; +enum class AmendmentSupport : int { Retired = -1, Supported = 0, Unsupported = 1 }; /** All amendments libxrpl knows about. */ std::map const& @@ -375,8 +375,10 @@ void foreachFeature(FeatureBitset bs, F&& f) { for (size_t i = 0; i < bs.size(); ++i) + { if (bs[i]) f(bitsetIndexToFeature(i)); + } } #pragma push_macro("XRPL_FEATURE") diff --git a/include/xrpl/protocol/IOUAmount.h b/include/xrpl/protocol/IOUAmount.h index 47aa35e0e8..1744345a1b 100644 --- a/include/xrpl/protocol/IOUAmount.h +++ b/include/xrpl/protocol/IOUAmount.h @@ -151,7 +151,9 @@ operator bool() const noexcept inline int IOUAmount::signum() const noexcept { - return (mantissa_ < 0) ? -1 : (mantissa_ ? 1 : 0); + if (mantissa_ < 0) + return -1; + return (mantissa_ != 0) ? 1 : 0; } inline IOUAmount::exponent_type diff --git a/include/xrpl/protocol/Issue.h b/include/xrpl/protocol/Issue.h index 7bd01185c9..569b01725d 100644 --- a/include/xrpl/protocol/Issue.h +++ b/include/xrpl/protocol/Issue.h @@ -12,8 +12,8 @@ namespace xrpl { class Issue { public: - Currency currency{}; - AccountID account{}; + Currency currency; + AccountID account; Issue() = default; @@ -68,7 +68,7 @@ hash_append(Hasher& h, Issue const& r) /** Equality comparison. */ /** @{ */ -[[nodiscard]] inline constexpr bool +[[nodiscard]] constexpr bool operator==(Issue const& lhs, Issue const& rhs) { return (lhs.currency == rhs.currency) && (isXRP(lhs.currency) || lhs.account == rhs.account); diff --git a/include/xrpl/protocol/LedgerHeader.h b/include/xrpl/protocol/LedgerHeader.h index 6e22ad268d..1035e5e892 100644 --- a/include/xrpl/protocol/LedgerHeader.h +++ b/include/xrpl/protocol/LedgerHeader.h @@ -19,7 +19,7 @@ struct LedgerHeader // LedgerIndex seq = 0; - NetClock::time_point parentCloseTime = {}; + NetClock::time_point parentCloseTime; // // For closed ledgers @@ -49,7 +49,7 @@ struct LedgerHeader // closed. For open ledgers, the time the ledger // will close if there's no transactions. // - NetClock::time_point closeTime = {}; + NetClock::time_point closeTime; }; // ledger close flags diff --git a/include/xrpl/protocol/MPTAmount.h b/include/xrpl/protocol/MPTAmount.h index 33b6e5abe4..4a6297cc74 100644 --- a/include/xrpl/protocol/MPTAmount.h +++ b/include/xrpl/protocol/MPTAmount.h @@ -109,7 +109,9 @@ operator bool() const noexcept constexpr int MPTAmount::signum() const noexcept { - return (value_ < 0) ? -1 : (value_ ? 1 : 0); + if (value_ < 0) + return -1; + return (value_ != 0) ? 1 : 0; } /** Returns the underlying value. Code SHOULD NOT call this @@ -141,7 +143,7 @@ mulRatio(MPTAmount const& amt, std::uint32_t num, std::uint32_t den, bool roundU { using namespace boost::multiprecision; - if (!den) + if (den == 0u) Throw("division by zero"); int128_t const amt128(amt.value()); diff --git a/include/xrpl/protocol/MPTIssue.h b/include/xrpl/protocol/MPTIssue.h index 60b7072902..727aef9008 100644 --- a/include/xrpl/protocol/MPTIssue.h +++ b/include/xrpl/protocol/MPTIssue.h @@ -47,14 +47,14 @@ public: friend constexpr std::weak_ordering operator<=>(MPTIssue const& lhs, MPTIssue const& rhs); - bool - native() const + static bool + native() { return false; } - bool - integral() const + static bool + integral() { return true; } @@ -94,9 +94,9 @@ getMPTIssuer(MPTID const& mptid) } // Disallow temporary -inline AccountID const& +AccountID const& getMPTIssuer(MPTID const&&) = delete; -inline AccountID const& +AccountID const& getMPTIssuer(MPTID&&) = delete; inline MPTID diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 1ebe72f15e..8d287767a6 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -74,10 +74,14 @@ struct MultiApiJson { int count = 0; for (auto& a : this->val) + { if (a.isMember(key)) count += 1; + } - return (count == 0 ? none : (count < size ? some : all)); + if (count == 0) + return none; + return count < size ? some : all; } static constexpr struct visitor_t final diff --git a/include/xrpl/protocol/PathAsset.h b/include/xrpl/protocol/PathAsset.h index 31bd8f384f..662e568bec 100644 --- a/include/xrpl/protocol/PathAsset.h +++ b/include/xrpl/protocol/PathAsset.h @@ -100,9 +100,13 @@ operator==(PathAsset const& lhs, PathAsset const& rhs) return std::visit( [](TLhs const& lhs_, TRhs const& rhs_) { if constexpr (std::is_same_v) + { return lhs_ == rhs_; + } else + { return false; + } }, lhs.value(), rhs.value()); diff --git a/include/xrpl/protocol/PublicKey.h b/include/xrpl/protocol/PublicKey.h index 64ced93ffb..9003175f3d 100644 --- a/include/xrpl/protocol/PublicKey.h +++ b/include/xrpl/protocol/PublicKey.h @@ -69,8 +69,8 @@ public: return buf_; } - std::size_t - size() const noexcept + static std::size_t + size() noexcept { return size_; } diff --git a/include/xrpl/protocol/Quality.h b/include/xrpl/protocol/Quality.h index 851e34d396..a58b89aaf8 100644 --- a/include/xrpl/protocol/Quality.h +++ b/include/xrpl/protocol/Quality.h @@ -281,7 +281,7 @@ public: double const minVD = static_cast(minVMantissa); double const maxVD = - expDiff ? maxVMantissa * pow(10, expDiff) : static_cast(maxVMantissa); + (expDiff != 0) ? maxVMantissa * pow(10, expDiff) : static_cast(maxVMantissa); // maxVD and minVD are scaled so they have the same exponents. Dividing // cancels out the exponents, so we only need to deal with the (scaled) diff --git a/include/xrpl/protocol/STAmount.h b/include/xrpl/protocol/STAmount.h index e33d7f0df4..55ffc81098 100644 --- a/include/xrpl/protocol/STAmount.h +++ b/include/xrpl/protocol/STAmount.h @@ -48,7 +48,7 @@ public: // Maximum native value supported by the code constexpr static std::uint64_t cMinValue = 1'000'000'000'000'000ull; static_assert(isPowerOfTen(cMinValue)); - constexpr static std::uint64_t cMaxValue = cMinValue * 10 - 1; + constexpr static std::uint64_t cMaxValue = (cMinValue * 10) - 1; static_assert(cMaxValue == 9'999'999'999'999'999ull); constexpr static std::uint64_t cMaxNative = 9'000'000'000'000'000'000ull; @@ -359,9 +359,13 @@ inline STAmount::STAmount(IOUAmount const& amount, Issue const& issue) : mAsset(issue), mOffset(amount.exponent()), mIsNegative(amount < beast::zero) { if (mIsNegative) + { mValue = unsafe_cast(-amount.mantissa()); + } else + { mValue = unsafe_cast(amount.mantissa()); + } canonicalize(); } @@ -370,9 +374,13 @@ inline STAmount::STAmount(MPTAmount const& amount, MPTIssue const& mptIssue) : mAsset(mptIssue), mOffset(0), mIsNegative(amount < beast::zero) { if (mIsNegative) + { mValue = unsafe_cast(-amount.value()); + } else + { mValue = unsafe_cast(amount.value()); + } canonicalize(); } @@ -476,7 +484,9 @@ STAmount::getIssuer() const inline int STAmount::signum() const noexcept { - return mValue ? (mIsNegative ? -1 : 1) : 0; + if (mValue == 0u) + return 0; + return mIsNegative ? -1 : 1; } inline STAmount diff --git a/include/xrpl/protocol/STBlob.h b/include/xrpl/protocol/STBlob.h index 71d1a04478..b9dc78ffe4 100644 --- a/include/xrpl/protocol/STBlob.h +++ b/include/xrpl/protocol/STBlob.h @@ -95,7 +95,7 @@ STBlob::size() const inline std::uint8_t const* STBlob::data() const { - return reinterpret_cast(value_.data()); + return value_.data(); } inline STBlob& diff --git a/include/xrpl/protocol/STCurrency.h b/include/xrpl/protocol/STCurrency.h index dc5b079c6d..5fd4c08fbb 100644 --- a/include/xrpl/protocol/STCurrency.h +++ b/include/xrpl/protocol/STCurrency.h @@ -11,7 +11,7 @@ namespace xrpl { class STCurrency final : public STBase { private: - Currency currency_{}; + Currency currency_; public: using value_type = Currency; diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index 561758df16..7e996828af 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -704,7 +704,7 @@ class STObject::FieldErr : public std::runtime_error template STObject::Proxy::Proxy(STObject* st, TypedField const* f) : st_(st), f_(f) { - if (st_->mType) + if (st_->mType != nullptr) { // STObject has associated template if (!st_->peekAtPField(*f_)) @@ -770,9 +770,13 @@ STObject::Proxy::assign(U&& u) } T* t = nullptr; if (style_ == soeINVALID) + { t = dynamic_cast(st_->getPField(*f_, true)); + } else + { t = dynamic_cast(st_->makeFieldPresent(*f_)); + } XRPL_ASSERT(t, "xrpl::STObject::Proxy::assign : type cast succeeded"); *t = std::forward(u); } @@ -858,9 +862,13 @@ STObject::OptionalProxy::operator=( -> OptionalProxy& { if (v) + { this->assign(std::move(*v)); + } else + { disengage(); + } return *this; } @@ -869,9 +877,13 @@ auto STObject::OptionalProxy::operator=(optional_type const& v) -> OptionalProxy& { if (v) + { this->assign(*v); + } else + { disengage(); + } return *this; } @@ -903,9 +915,13 @@ STObject::OptionalProxy::disengage() if (this->style_ == soeREQUIRED || this->style_ == soeDEFAULT) Throw("Template field error '" + this->f_->getName() + "'"); if (this->style_ == soeINVALID) + { this->st_->delField(*this->f_); + } else + { this->st_->makeFieldAbsent(*this->f_); + } } template @@ -1058,9 +1074,11 @@ STObject::at(TypedField const& f) const { auto const b = peekAtPField(f); if (!b) + { // This is a free object (no constraints) // with no template Throw("Missing field: " + f.getName()); + } if (auto const u = dynamic_cast(b)) return u->value(); @@ -1138,9 +1156,13 @@ STObject::setFieldH160(SField const& field, base_uint<160, Tag> const& v) using Bits = STBitString<160>; if (auto cf = dynamic_cast(rf)) + { cf->setValue(v); + } else + { Throw("Wrong field type"); + } } inline bool @@ -1188,8 +1210,10 @@ STObject::getFieldByConstRef(SField const& field, V const& empty) const SerializedTypeID const id = rf->getSType(); if (id == STI_NOTPRESENT) + { // NOLINTNEXTLINE(bugprone-return-const-ref-from-parameter) return empty; // optional field not present + } T const* cf = dynamic_cast(rf); diff --git a/include/xrpl/protocol/STValidation.h b/include/xrpl/protocol/STValidation.h index 861e2152f8..c645336b59 100644 --- a/include/xrpl/protocol/STValidation.h +++ b/include/xrpl/protocol/STValidation.h @@ -36,7 +36,7 @@ class STValidation final : public STObject, public CountedObject // that use manifests this will be derived from the master public key. NodeID const nodeID_; - NetClock::time_point seenTime_ = {}; + NetClock::time_point seenTime_; public: /** Construct a STValidation from a peer from serialized data. diff --git a/include/xrpl/protocol/STVector256.h b/include/xrpl/protocol/STVector256.h index 815224def2..69b06ec1da 100644 --- a/include/xrpl/protocol/STVector256.h +++ b/include/xrpl/protocol/STVector256.h @@ -148,7 +148,7 @@ STVector256::size() const inline void STVector256::resize(std::size_t n) { - return mValue.resize(n); + mValue.resize(n); } inline bool @@ -220,7 +220,7 @@ STVector256::erase(std::vector::iterator position) inline void STVector256::clear() noexcept { - return mValue.clear(); + mValue.clear(); } } // namespace xrpl diff --git a/include/xrpl/protocol/SecretKey.h b/include/xrpl/protocol/SecretKey.h index 530b6fc35f..c17b3984e9 100644 --- a/include/xrpl/protocol/SecretKey.h +++ b/include/xrpl/protocol/SecretKey.h @@ -85,10 +85,10 @@ public: } }; -inline bool +bool operator==(SecretKey const& lhs, SecretKey const& rhs) = delete; -inline bool +bool operator!=(SecretKey const& lhs, SecretKey const& rhs) = delete; //------------------------------------------------------------------------------ diff --git a/include/xrpl/protocol/Serializer.h b/include/xrpl/protocol/Serializer.h index 2d3489fe7b..6ce60022e3 100644 --- a/include/xrpl/protocol/Serializer.h +++ b/include/xrpl/protocol/Serializer.h @@ -33,7 +33,7 @@ public: { mData.resize(size); - if (size) + if (size != 0u) { XRPL_ASSERT(data, "xrpl::Serializer::Serializer(void const*) : non-null input"); std::memcpy(mData.data(), data, size); diff --git a/include/xrpl/protocol/Units.h b/include/xrpl/protocol/Units.h index 196464fa16..b606ca2cdf 100644 --- a/include/xrpl/protocol/Units.h +++ b/include/xrpl/protocol/Units.h @@ -267,7 +267,9 @@ public: constexpr int signum() const noexcept { - return (value_ < 0) ? -1 : (value_ ? 1 : 0); + if (value_ < 0) + return -1; + return value_ ? 1 : 0; } /** Returns the number of drops */ diff --git a/include/xrpl/protocol/XRPAmount.h b/include/xrpl/protocol/XRPAmount.h index 6e4133361b..0cb5121ef1 100644 --- a/include/xrpl/protocol/XRPAmount.h +++ b/include/xrpl/protocol/XRPAmount.h @@ -149,7 +149,9 @@ public: constexpr int signum() const noexcept { - return (drops_ < 0) ? -1 : (drops_ ? 1 : 0); + if (drops_ < 0) + return -1; + return (drops_ != 0) ? 1 : 0; } /** Returns the number of drops */ @@ -262,7 +264,7 @@ mulRatio(XRPAmount const& amt, std::uint32_t num, std::uint32_t den, bool roundU { using namespace boost::multiprecision; - if (!den) + if (den == 0u) Throw("division by zero"); int128_t const amt128(amt.drops()); diff --git a/include/xrpl/protocol/detail/STVar.h b/include/xrpl/protocol/detail/STVar.h index 1131437850..6984c29525 100644 --- a/include/xrpl/protocol/detail/STVar.h +++ b/include/xrpl/protocol/detail/STVar.h @@ -112,9 +112,13 @@ private: construct(Args&&... args) { if constexpr (sizeof(T) > max_size) + { p_ = new T(std::forward(args)...); + } else + { p_ = new (&d_) T(std::forward(args)...); + } } /** Construct requested Serializable Type according to id. diff --git a/include/xrpl/protocol/detail/b58_utils.h b/include/xrpl/protocol/detail/b58_utils.h index 5ad12d56e3..4332d29e5f 100644 --- a/include/xrpl/protocol/detail/b58_utils.h +++ b/include/xrpl/protocol/detail/b58_utils.h @@ -33,7 +33,7 @@ carrying_mul(std::uint64_t a, std::uint64_t b, std::uint64_t carry) { unsigned __int128 const x = a; unsigned __int128 const y = b; - unsigned __int128 const c = x * y + carry; + unsigned __int128 const c = (x * y) + carry; return {c & 0xffff'ffff'ffff'ffff, c >> 64}; } @@ -64,13 +64,13 @@ inplace_bigint_add(std::span a, std::uint64_t b) for (auto& v : a.subspan(1)) { - if (!carry) + if (carry == 0u) { return TokenCodecErrc::success; } std::tie(v, carry) = carrying_add(v, 1); } - if (carry) + if (carry != 0u) { return TokenCodecErrc::overflowAdd; } @@ -105,7 +105,7 @@ inplace_bigint_mul(std::span a, std::uint64_t b) [[nodiscard]] inline std::uint64_t inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) { - if (numerator.size() == 0) + if (numerator.empty()) { // should never happen, but if it does then it seems natural to define // the a null set of numbers to be zero, so the remainder is also zero. diff --git a/include/xrpl/protocol/digest.h b/include/xrpl/protocol/digest.h index 7664069e1c..bbb38fa543 100644 --- a/include/xrpl/protocol/digest.h +++ b/include/xrpl/protocol/digest.h @@ -177,12 +177,12 @@ public: } private: - inline void + void erase(std::false_type) { } - inline void + void erase(std::true_type) { secure_erase(&h_, sizeof(h_)); diff --git a/include/xrpl/resource/detail/Entry.h b/include/xrpl/resource/detail/Entry.h index 2a6414778c..2e71b7cf17 100644 --- a/include/xrpl/resource/detail/Entry.h +++ b/include/xrpl/resource/detail/Entry.h @@ -22,7 +22,7 @@ struct Entry : public beast::List::Node @param now Construction time of Entry. */ explicit Entry(clock_type::time_point const now) - : refcount(0), local_balance(now), remote_balance(0), lastWarningTime(), whenExpires() + : refcount(0), local_balance(now), remote_balance(0) { } diff --git a/include/xrpl/resource/detail/Import.h b/include/xrpl/resource/detail/Import.h index bee90afbf0..0377910990 100644 --- a/include/xrpl/resource/detail/Import.h +++ b/include/xrpl/resource/detail/Import.h @@ -18,7 +18,7 @@ struct Import }; // Dummy argument required for zero-copy construction - Import(int = 0) : whenExpires() + Import(int = 0) { } diff --git a/include/xrpl/resource/detail/Logic.h b/include/xrpl/resource/detail/Logic.h index 66c47bc538..0682c4a7e9 100644 --- a/include/xrpl/resource/detail/Logic.h +++ b/include/xrpl/resource/detail/Logic.h @@ -352,7 +352,9 @@ public: iter = importTable_.erase(iter); } else + { ++iter; + } } } @@ -506,7 +508,7 @@ public: //-------------------------------------------------------------------------- - void + static void writeList( clock_type::time_point const now, beast::PropertyStream::Set& items, diff --git a/include/xrpl/server/LoadFeeTrack.h b/include/xrpl/server/LoadFeeTrack.h index 226408dbde..6b9e96241c 100644 --- a/include/xrpl/server/LoadFeeTrack.h +++ b/include/xrpl/server/LoadFeeTrack.h @@ -60,8 +60,8 @@ public: return clusterTxnLoadFee_; } - std::uint32_t - getLoadBase() const + static std::uint32_t + getLoadBase() { return lftNormalFee; } diff --git a/include/xrpl/server/NetworkOPs.h b/include/xrpl/server/NetworkOPs.h index 16ec4a4ec0..b8f50dcd42 100644 --- a/include/xrpl/server/NetworkOPs.h +++ b/include/xrpl/server/NetworkOPs.h @@ -73,7 +73,7 @@ public: using clock_type = beast::abstract_clock; enum class FailHard : unsigned char { no, yes }; - static inline FailHard + static FailHard doFailHard(bool noMeansDont) { return noMeansDont ? FailHard::yes : FailHard::no; diff --git a/include/xrpl/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index 878f6a1ddf..1e68d5c81c 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -219,10 +219,12 @@ void BaseHTTPPeer::close() { if (!strand_.running_in_this_thread()) + { return post( strand_, std::bind( (void (BaseHTTPPeer::*)(void))&BaseHTTPPeer::close, impl().shared_from_this())); + } boost::beast::get_lowest_layer(impl().stream_).close(); } @@ -398,11 +400,12 @@ BaseHTTPPeer::write(void const* buf, std::size_t bytes) }()) { if (!strand_.running_in_this_thread()) + { return post( strand_, std::bind(&BaseHTTPPeer::on_write, impl().shared_from_this(), error_code{}, 0)); - else - return on_write(error_code{}, 0); + } + return on_write(error_code{}, 0); } } @@ -436,8 +439,10 @@ void BaseHTTPPeer::complete() { if (!strand_.running_in_this_thread()) + { return post( strand_, std::bind(&BaseHTTPPeer::complete, impl().shared_from_this())); + } message_ = {}; complete_ = true; @@ -464,12 +469,14 @@ void BaseHTTPPeer::close(bool graceful) { if (!strand_.running_in_this_thread()) + { return post( strand_, std::bind( (void (BaseHTTPPeer::*)(bool))&BaseHTTPPeer::close, impl().shared_from_this(), graceful)); + } complete_ = true; if (graceful) diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index ebc504a863..51e089fde5 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -285,6 +285,7 @@ BaseWSPeer::on_write(error_code const& ec) return; start_timer(); if (!result.first) + { impl().ws_.async_write_some( static_cast(result.first), result.second, @@ -292,7 +293,9 @@ BaseWSPeer::on_write(error_code const& ec) strand_, std::bind( &BaseWSPeer::on_write, impl().shared_from_this(), std::placeholders::_1))); + } else + { impl().ws_.async_write_some( static_cast(result.first), result.second, @@ -300,6 +303,7 @@ BaseWSPeer::on_write(error_code const& ec) strand_, std::bind( &BaseWSPeer::on_write_fin, impl().shared_from_this(), std::placeholders::_1))); + } } template @@ -319,7 +323,9 @@ BaseWSPeer::on_write_fin(error_code const& ec) &BaseWSPeer::on_close, impl().shared_from_this(), std::placeholders::_1))); } else if (!wq_.empty()) + { on_write({}); + } } template diff --git a/include/xrpl/server/detail/Door.h b/include/xrpl/server/detail/Door.h index 87baad42db..6194e62d3c 100644 --- a/include/xrpl/server/detail/Door.h +++ b/include/xrpl/server/detail/Door.h @@ -93,7 +93,7 @@ private: 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")}; + (port_.protocol.count("ws2") != 0u)}; 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}; @@ -297,8 +297,10 @@ void Door::close() { if (!strand_.running_in_this_thread()) + { return boost::asio::post( strand_, std::bind(&Door::close, this->shared_from_this())); + } backoff_timer_.cancel(); error_code ec; acceptor_.close(ec); @@ -432,11 +434,7 @@ Door::should_throttle_for_fds() auto const& s = *stats; auto const free = (s.limit > s.used) ? (s.limit - s.used) : 0ull; double const free_ratio = static_cast(free) / static_cast(s.limit); - if (free_ratio < FREE_FD_THRESHOLD) - { - return true; - } - return false; + return free_ratio < FREE_FD_THRESHOLD; #endif } diff --git a/include/xrpl/server/detail/ServerImpl.h b/include/xrpl/server/detail/ServerImpl.h index 0b5d075d87..ce1ca13664 100644 --- a/include/xrpl/server/detail/ServerImpl.h +++ b/include/xrpl/server/detail/ServerImpl.h @@ -155,7 +155,7 @@ ServerImpl::ports(std::vector const& ports) list_.push_back(sp); auto ep = sp->get_endpoint(); - if (!internalPort.port) + if (internalPort.port == 0u) internalPort.port = ep.port(); eps.emplace(port.name, std::move(ep)); diff --git a/include/xrpl/server/detail/io_list.h b/include/xrpl/server/detail/io_list.h index f1cc04f683..b36c54a1f4 100644 --- a/include/xrpl/server/detail/io_list.h +++ b/include/xrpl/server/detail/io_list.h @@ -223,8 +223,10 @@ io_list::close(Finisher&& f) f_ = std::forward(f); lock.unlock(); for (auto const& p : map) + { if (auto sp = p.second.lock()) sp->close(); + } } else { diff --git a/include/xrpl/shamap/SHAMap.h b/include/xrpl/shamap/SHAMap.h index 213e7ce0ce..43b2734d65 100644 --- a/include/xrpl/shamap/SHAMap.h +++ b/include/xrpl/shamap/SHAMap.h @@ -94,10 +94,10 @@ private: public: /** Number of children each non-leaf node has (the 'radix tree' part of the * map) */ - static inline constexpr unsigned int branchFactor = SHAMapInnerNode::branchFactor; + static constexpr unsigned int branchFactor = SHAMapInnerNode::branchFactor; /** The depth of the hash map: data is only present in the leaves */ - static inline constexpr unsigned int leafDepth = 64; + static constexpr unsigned int leafDepth = 64; using DeltaItem = std::pair, boost::intrusive_ptr>; @@ -658,9 +658,13 @@ inline SHAMap::const_iterator& SHAMap::const_iterator::operator++() { if (auto temp = map_->peekNextItem(item_->key(), stack_)) + { item_ = temp->peekItem().get(); + } else + { item_ = nullptr; + } return *this; } diff --git a/include/xrpl/shamap/SHAMapInnerNode.h b/include/xrpl/shamap/SHAMapInnerNode.h index 73d59cc1fe..ebaad0d6f7 100644 --- a/include/xrpl/shamap/SHAMapInnerNode.h +++ b/include/xrpl/shamap/SHAMapInnerNode.h @@ -15,7 +15,7 @@ class SHAMapInnerNode final : public SHAMapTreeNode, public CountedObject afterVault_ = {}; - std::vector afterMPTs_ = {}; - std::vector beforeVault_ = {}; - std::vector beforeMPTs_ = {}; - std::unordered_map deltas_ = {}; + std::vector afterVault_; + std::vector afterMPTs_; + std::vector beforeVault_; + std::vector beforeMPTs_; + std::unordered_map deltas_; public: void diff --git a/include/xrpl/tx/paths/Offer.h b/include/xrpl/tx/paths/Offer.h index ae7a47061a..0ef2a30052 100644 --- a/include/xrpl/tx/paths/Offer.h +++ b/include/xrpl/tx/paths/Offer.h @@ -173,14 +173,22 @@ void TOffer::setFieldAmounts() { if constexpr (std::is_same_v) + { m_entry->setFieldAmount(sfTakerPays, toSTAmount(m_amounts.in)); + } else + { m_entry->setFieldAmount(sfTakerPays, toSTAmount(m_amounts.in, assetIn_)); + } if constexpr (std::is_same_v) + { m_entry->setFieldAmount(sfTakerGets, toSTAmount(m_amounts.out)); + } else + { m_entry->setFieldAmount(sfTakerGets, toSTAmount(m_amounts.out, assetOut_)); + } } template @@ -200,11 +208,13 @@ TOffer::limitIn(TAmounts const& offerAmount, TIn const& li { if (auto const& rules = getCurrentTransactionRules(); rules && rules->enabled(fixReducedOffersV2)) + { // It turns out that the ceil_in implementation has some slop in // it. ceil_in_strict removes that slop. But removing that slop // affects transaction outcomes, so the change must be made using // an amendment. return quality().ceil_in_strict(offerAmount, limit, roundUp); + } return m_quality.ceil_in(offerAmount, limit); } diff --git a/include/xrpl/tx/paths/detail/FlowDebugInfo.h b/include/xrpl/tx/paths/detail/FlowDebugInfo.h index dd25939d27..ce46d0dcde 100644 --- a/include/xrpl/tx/paths/detail/FlowDebugInfo.h +++ b/include/xrpl/tx/paths/detail/FlowDebugInfo.h @@ -255,28 +255,44 @@ struct FlowDebugInfo ostr << ", in_pass: "; if (passInfo.nativeIn) + { writeXrpAmtList(passInfo.in); + } else + { writeIouAmtList(passInfo.in); + } ostr << ", out_pass: "; if (passInfo.nativeOut) + { writeXrpAmtList(passInfo.out); + } else + { writeIouAmtList(passInfo.out); + } ostr << ", num_active: "; writeIntList(passInfo.numActive); if (!passInfo.liquiditySrcIn.empty() && !passInfo.liquiditySrcIn.back().empty()) { ostr << ", l_src_in: "; if (passInfo.nativeIn) + { writeNestedXrpAmtList(passInfo.liquiditySrcIn); + } else + { writeNestedIouAmtList(passInfo.liquiditySrcIn); + } ostr << ", l_src_out: "; if (passInfo.nativeOut) + { writeNestedXrpAmtList(passInfo.liquiditySrcOut); + } else + { writeNestedIouAmtList(passInfo.liquiditySrcOut); + } } } diff --git a/include/xrpl/tx/paths/detail/StepChecks.h b/include/xrpl/tx/paths/detail/StepChecks.h index 7ad9279c87..a1e6490781 100644 --- a/include/xrpl/tx/paths/detail/StepChecks.h +++ b/include/xrpl/tx/paths/detail/StepChecks.h @@ -77,8 +77,8 @@ checkNoRipple( if (!sleIn || !sleOut) return terNO_LINE; - if ((*sleIn)[sfFlags] & ((cur > prev) ? lsfHighNoRipple : lsfLowNoRipple) && - (*sleOut)[sfFlags] & ((cur > next) ? lsfHighNoRipple : lsfLowNoRipple)) + if ((((*sleIn)[sfFlags] & ((cur > prev) ? lsfHighNoRipple : lsfLowNoRipple)) != 0u) && + (((*sleOut)[sfFlags] & ((cur > next) ? lsfHighNoRipple : lsfLowNoRipple)) != 0u)) { JLOG(j.info()) << "Path violates noRipple constraint between " << prev << ", " << cur << " and " << next; diff --git a/include/xrpl/tx/paths/detail/Steps.h b/include/xrpl/tx/paths/detail/Steps.h index c3269505b1..c46cebca88 100644 --- a/include/xrpl/tx/paths/detail/Steps.h +++ b/include/xrpl/tx/paths/detail/Steps.h @@ -288,10 +288,10 @@ private: inline std::pair, DebtDirection> Step::getQualityFunc(ReadView const& v, DebtDirection prevStepDir) const { - if (auto const res = qualityUpperBound(v, prevStepDir); res.first) + auto const res = qualityUpperBound(v, prevStepDir); + if (res.first) return {QualityFunction{*res.first, QualityFunction::CLOBLikeTag{}}, res.second}; - else - return {std::nullopt, res.second}; + return {std::nullopt, res.second}; } /// @cond INTERNAL @@ -317,8 +317,10 @@ operator==(Strand const& lhs, Strand const& rhs) if (lhs.size() != rhs.size()) return false; for (size_t i = 0, e = lhs.size(); i != e; ++i) + { if (*lhs[i] != *rhs[i]) return false; + } return true; } /// @endcond @@ -635,9 +637,13 @@ bool isDirectXrpToXrp(Strand const& strand) { if constexpr (std::is_same_v && std::is_same_v) + { return strand.size() == 2; + } else + { return false; + } } /// @endcond diff --git a/include/xrpl/tx/paths/detail/StrandFlow.h b/include/xrpl/tx/paths/detail/StrandFlow.h index 9892facee3..d7250dbdc3 100644 --- a/include/xrpl/tx/paths/detail/StrandFlow.h +++ b/include/xrpl/tx/paths/detail/StrandFlow.h @@ -327,9 +327,13 @@ qualityUpperBound(ReadView const& v, Strand const& strand) for (auto const& step : strand) { if (std::tie(stepQ, dir) = step->qualityUpperBound(v, dir); stepQ) + { q = composed_quality(q, *stepQ); + } else + { return std::nullopt; + } } return q; }; @@ -360,12 +364,18 @@ limitOut( if (std::tie(stepQualityFunc, dir) = step->getQualityFunc(v, dir); stepQualityFunc) { if (!qf) + { qf = stepQualityFunc; + } else + { qf->combine(*stepQualityFunc); + } } else + { return remainingOut; + } } // QualityFunction is constant @@ -373,16 +383,25 @@ limitOut( return remainingOut; auto const out = [&]() { - if (auto const out = qf->outFromAvgQ(limitQuality); !out) + auto const out = qf->outFromAvgQ(limitQuality); + if (!out) return remainingOut; - else if constexpr (std::is_same_v) + if constexpr (std::is_same_v) + { return XRPAmount{*out}; + } else if constexpr (std::is_same_v) + { return IOUAmount{*out}; + } else if constexpr (std::is_same_v) + { return MPTAmount{*out}; + } else + { return STAmount{remainingOut.asset(), out->mantissa(), out->exponent()}; + } }(); // A tiny difference could be due to the round off if (withinRelativeDistance(out, remainingOut, Number(1, -9))) @@ -432,7 +451,7 @@ public: { for (Strand const* strand : next_) { - if (!strand) + if (strand == nullptr) { // should not happen continue; @@ -627,8 +646,10 @@ flow( // Limit only if one strand and limitQuality auto const limitRemainingOut = [&]() { if (activeStrands.size() == 1 && limitQuality) + { if (auto const strand = activeStrands.get(0)) return limitOut(sb, *strand, remainingOut, *limitQuality); + } return remainingOut; }(); auto const adjustedRemOut = limitRemainingOut != remainingOut; @@ -717,8 +738,10 @@ flow( remainingIn = *sendMax - sum(savedIns); if (flowDebugInfo) + { flowDebugInfo->pushPass( EitherAmount(best->in), EitherAmount(best->out), activeStrands.size()); + } JLOG(j.trace()) << "Best path: in: " << to_string(best->in) << " out: " << to_string(best->out) diff --git a/include/xrpl/tx/transactors/token/MPTokenAuthorize.h b/include/xrpl/tx/transactors/token/MPTokenAuthorize.h index 3210608e73..67ea9d3023 100644 --- a/include/xrpl/tx/transactors/token/MPTokenAuthorize.h +++ b/include/xrpl/tx/transactors/token/MPTokenAuthorize.h @@ -10,7 +10,7 @@ struct MPTAuthorizeArgs MPTID const& mptIssuanceID; AccountID const& account; std::uint32_t flags{}; - std::optional holderID{}; + std::optional holderID; }; class MPTokenAuthorize : public Transactor diff --git a/include/xrpl/tx/transactors/token/MPTokenIssuanceCreate.h b/include/xrpl/tx/transactors/token/MPTokenIssuanceCreate.h index 5ef12df282..8518ba2f64 100644 --- a/include/xrpl/tx/transactors/token/MPTokenIssuanceCreate.h +++ b/include/xrpl/tx/transactors/token/MPTokenIssuanceCreate.h @@ -12,12 +12,16 @@ struct MPTCreateArgs AccountID const& account; std::uint32_t sequence = 0; std::uint32_t flags = 0; - std::optional maxAmount{}; - std::optional assetScale{}; - std::optional transferFee{}; + std::optional maxAmount = + std::nullopt; // NOLINT(readability-redundant-member-init) + std::optional assetScale = + std::nullopt; // NOLINT(readability-redundant-member-init) + std::optional transferFee = + std::nullopt; // NOLINT(readability-redundant-member-init) std::optional const& metadata{}; - std::optional domainId{}; - std::optional mutableFlags{}; + std::optional domainId = std::nullopt; // NOLINT(readability-redundant-member-init) + std::optional mutableFlags = + std::nullopt; // NOLINT(readability-redundant-member-init) }; class MPTokenIssuanceCreate : public Transactor diff --git a/src/libxrpl/beast/utility/beast_PropertyStream.cpp b/src/libxrpl/beast/utility/beast_PropertyStream.cpp index 662d763ce0..13f54587ec 100644 --- a/src/libxrpl/beast/utility/beast_PropertyStream.cpp +++ b/src/libxrpl/beast/utility/beast_PropertyStream.cpp @@ -15,7 +15,7 @@ namespace beast { // //------------------------------------------------------------------------------ -PropertyStream::Item::Item(Source* source) : ListNode(), m_source(source) +PropertyStream::Item::Item(Source* source) : m_source(source) { } diff --git a/src/libxrpl/ledger/ApplyView.cpp b/src/libxrpl/ledger/ApplyView.cpp index 3ceddaa4dc..657d2d6fbd 100644 --- a/src/libxrpl/ledger/ApplyView.cpp +++ b/src/libxrpl/ledger/ApplyView.cpp @@ -41,8 +41,10 @@ findPreviousPage(ApplyView& view, Keylet const& directory, SLE::ref start) { node = view.peek(keylet::page(directory, page)); if (!node) + { Throw( "Directory chain: root back-pointer broken."); // LCOV_EXCL_LINE + } } auto indexes = node->getFieldV256(sfIndexes); diff --git a/src/libxrpl/ledger/PaymentSandbox.cpp b/src/libxrpl/ledger/PaymentSandbox.cpp index a46e22f404..1a5dfa40a6 100644 --- a/src/libxrpl/ledger/PaymentSandbox.cpp +++ b/src/libxrpl/ledger/PaymentSandbox.cpp @@ -239,7 +239,7 @@ DeferredCredits::apply(DeferredCredits& to) toVal.selfDebit += fromVal.selfDebit; for (auto& [k, v] : fromVal.holders) { - if (toVal.holders.find(k) == toVal.holders.end()) + if (!toVal.holders.contains(k)) { toVal.holders[k] = v; } diff --git a/src/libxrpl/tx/transactors/vault/VaultCreate.cpp b/src/libxrpl/tx/transactors/vault/VaultCreate.cpp index 02f8ecb57b..0f6c53f33b 100644 --- a/src/libxrpl/tx/transactors/vault/VaultCreate.cpp +++ b/src/libxrpl/tx/transactors/vault/VaultCreate.cpp @@ -181,8 +181,10 @@ VaultCreate::doApply() .sequence = 1, .flags = mptFlags, .assetScale = scale, + .transferFee = std::nullopt, .metadata = tx[~sfMPTokenMetadata], .domainId = tx[~sfDomainID], + .mutableFlags = std::nullopt, }); if (!maybeShare) return maybeShare.error(); // LCOV_EXCL_LINE diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index a434eb96c7..86df8ce12d 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -5932,6 +5932,7 @@ private: } void + // NOLINTNEXTLINE(readability-convert-member-functions-to-static) testFixOverflowOffer(FeatureBitset featuresInitial) { using namespace jtx; diff --git a/src/test/app/Vault_test.cpp b/src/test/app/Vault_test.cpp index 95b9165feb..a1921305ff 100644 --- a/src/test/app/Vault_test.cpp +++ b/src/test/app/Vault_test.cpp @@ -4837,8 +4837,8 @@ class Vault_test : public beast::unit_test::suite } }; - Account owner{"alice"}; - Account depositor{"bob"}; + Account const owner{"alice"}; + Account const depositor{"bob"}; Account const issuer{"issuer"}; env.fund(XRP(10000), issuer, owner, depositor); @@ -5337,7 +5337,7 @@ class Vault_test : public beast::unit_test::suite }; Account owner{"alice"}; - Account depositor{"bob"}; + Account const depositor{"bob"}; Account const issuer{"issuer"}; env.fund(XRP(10000), issuer, owner, depositor); diff --git a/src/test/csf/BasicNetwork.h b/src/test/csf/BasicNetwork.h index 85c77ac47d..384b4634ad 100644 --- a/src/test/csf/BasicNetwork.h +++ b/src/test/csf/BasicNetwork.h @@ -74,7 +74,7 @@ class BasicNetwork { bool inbound = false; duration delay{}; - time_point established{}; + time_point established; link_type() = default; link_type(bool inbound_, duration delay_, time_point established_) : inbound(inbound_), delay(delay_), established(established_) diff --git a/src/test/csf/Peer.h b/src/test/csf/Peer.h index fb1238990e..5bf2dcd719 100644 --- a/src/test/csf/Peer.h +++ b/src/test/csf/Peer.h @@ -62,8 +62,8 @@ struct Peer return proposal_.getJson(); } - std::string - render() const + static std::string + render() { return ""; } @@ -295,9 +295,13 @@ struct Peer using namespace std::chrono_literals; if (when == 0ns) + { what(); + } else + { scheduler.in(when, std::forward(what)); + } } // Issue a new event to the collectors @@ -340,8 +344,10 @@ struct Peer trusts(PeerID const& oId) { for (auto const p : trustGraph.trustedPeers(this)) + { if (p->id == oId) return true; + } return false; } @@ -774,7 +780,7 @@ struct Peer { // Ignore and suppress relay of transactions already in last ledger TxSetType const& lastClosedTxs = lastClosedLedger.txs(); - if (lastClosedTxs.find(tx) != lastClosedTxs.end()) + if (lastClosedTxs.contains(tx)) return false; // only relay if it was new to our open ledger @@ -830,8 +836,8 @@ struct Peer { } - bool - validating() const + static bool + validating() { // does not matter return false; diff --git a/src/test/csf/Scheduler.h b/src/test/csf/Scheduler.h index b92c4341b5..984d97e277 100644 --- a/src/test/csf/Scheduler.h +++ b/src/test/csf/Scheduler.h @@ -381,8 +381,10 @@ Scheduler::step() if (!step_one()) return false; for (;;) + { if (!step_one()) break; + } return true; } diff --git a/src/test/csf/Tx.h b/src/test/csf/Tx.h index 81393f7bda..fc57348443 100644 --- a/src/test/csf/Tx.h +++ b/src/test/csf/Tx.h @@ -183,9 +183,13 @@ operator<<(std::ostream& o, boost::container::flat_set const& ts) for (auto const& t : ts) { if (do_comma) + { o << ", "; + } else + { do_comma = true; + } o << t; } o << " }"; diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index cfe40330ff..ddd7c65784 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -134,7 +134,9 @@ struct SimDurationCollector init = true; } else + { stop = when; + } } }; diff --git a/src/test/csf/random.h b/src/test/csf/random.h index f3ecca1dbc..406252ff0d 100644 --- a/src/test/csf/random.h +++ b/src/test/csf/random.h @@ -111,7 +111,7 @@ public: } template - inline double + double operator()(Generator&) { return t_; @@ -140,7 +140,7 @@ public: } template - inline double + double operator()(Generator& g) { // use inverse transform of CDF to sample diff --git a/src/test/jtx/AMM.h b/src/test/jtx/AMM.h index 45f0e13797..5697952ada 100644 --- a/src/test/jtx/AMM.h +++ b/src/test/jtx/AMM.h @@ -99,7 +99,7 @@ struct BidArg std::optional account = std::nullopt; std::optional> bidMin = std::nullopt; std::optional> bidMax = std::nullopt; - std::vector authAccounts = {}; + std::vector authAccounts = {}; // NOLINT(readability-redundant-member-init) std::optional flags = std::nullopt; std::optional> assets = std::nullopt; }; @@ -372,13 +372,13 @@ public: } std::string - operator[](AccountID const& lp) + operator[](AccountID const& lp) const { return ammRpcInfo(lp).toStyledString(); } Json::Value - operator()(AccountID const& lp) + operator()(AccountID const& lp) const { return ammRpcInfo(lp); } @@ -425,9 +425,13 @@ public: auto const& jr = p.amm.ammRpcInfo(); auto out = [&](Json::Value const& jv) { if (jv.isMember(jss::value)) + { std::cout << jv[jss::value].asString(); + } else + { std::cout << jv.asString(); + } std::cout << " "; }; if (p.names.empty()) @@ -456,9 +460,13 @@ public: { auto out = [&](Json::Value const& jv) { if (jv.isMember(jss::value)) + { s << jv[jss::value].asString(); + } else + { s << jv; + } }; for (auto const& o : offers.jv[jss::offers]) { diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index d638d520ba..e88b07becd 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -85,9 +85,13 @@ testable_amendments() { (void)vote; if (auto const f = getRegisteredFeature(s)) + { feats.push_back(*f); + } else + { Throw("Unknown feature: " + s + " in allAmendments."); + } } return FeatureBitset(feats); }(); @@ -128,12 +132,12 @@ public: /// Used by parseResult() and postConditions() struct ParsedResult { - std::optional ter{}; + std::optional ter; // RPC errors tend to return either a "code" and a "message" (sometimes // with an "error" that corresponds to the "code"), or with an "error" // and an "exception". However, this structure allows all possible // combinations. - std::optional rpcCode{}; + std::optional rpcCode; std::string rpcMessage; std::string rpcError; std::string rpcException; @@ -256,6 +260,7 @@ public: virtual ~Env() = default; Application& + // NOLINTNEXTLINE(readability-make-member-function-const) app() { return *bundle_.app; @@ -268,6 +273,7 @@ public: } ManualTimeKeeper& + // NOLINTNEXTLINE(readability-make-member-function-const) timeKeeper() { return *bundle_.timeKeeper; @@ -279,6 +285,7 @@ public: close or by callers. */ NetClock::time_point + // NOLINTNEXTLINE(readability-make-member-function-const) now() { return timeKeeper().now(); @@ -286,6 +293,7 @@ public: /** Returns the connected client. */ AbstractClient& + // NOLINTNEXTLINE(readability-make-member-function-const) client() { return *bundle_.client; @@ -773,7 +781,7 @@ public: trust(STAmount const& amount, Account const& to0, Account const& to1, Accounts const&... toN) { trust(amount, to0); - trust(amount, to1, toN...); + trust(amount, to1, toN...); // NOLINT(readability-suspicious-call-argument) } /** @} */ diff --git a/src/test/jtx/ManualTimeKeeper.h b/src/test/jtx/ManualTimeKeeper.h index d5fdd467e1..b054db96dd 100644 --- a/src/test/jtx/ManualTimeKeeper.h +++ b/src/test/jtx/ManualTimeKeeper.h @@ -10,7 +10,7 @@ namespace test { class ManualTimeKeeper : public TimeKeeper { private: - std::atomic now_{}; + std::atomic now_; public: ManualTimeKeeper() = default; diff --git a/src/test/jtx/Oracle.h b/src/test/jtx/Oracle.h index 8f48ad4d37..c64334e5d4 100644 --- a/src/test/jtx/Oracle.h +++ b/src/test/jtx/Oracle.h @@ -58,7 +58,7 @@ struct UpdateArg { std::optional owner = std::nullopt; std::optional documentID = std::nullopt; - DataSeries series = {}; + DataSeries series = {}; // NOLINT(readability-redundant-member-init) std::optional assetClass = std::nullopt; std::optional provider = std::nullopt; std::optional uri = "URI"; diff --git a/src/test/jtx/TestHelpers.h b/src/test/jtx/TestHelpers.h index 0beca74e90..c0004e3d6a 100644 --- a/src/test/jtx/TestHelpers.h +++ b/src/test/jtx/TestHelpers.h @@ -994,9 +994,9 @@ struct IssuerArgs { jtx::Env& env; // 3-letter currency if Issue, ignored if MPT - std::string token = ""; + std::string token; jtx::Account issuer; - std::vector holders = {}; + std::vector holders = {}; // NOLINT(readability-redundant-member-init) // trust-limit if Issue, maxAmount if MPT std::optional limit = std::nullopt; // 0-50'000 (0-50%) diff --git a/src/test/jtx/TrustedPublisherServer.h b/src/test/jtx/TrustedPublisherServer.h index 806e60f92a..b0a8e3a017 100644 --- a/src/test/jtx/TrustedPublisherServer.h +++ b/src/test/jtx/TrustedPublisherServer.h @@ -54,7 +54,7 @@ class TrustedPublisherServer : public std::enable_shared_from_this( path.substr(strlen(refreshPrefix))); + } res.body() = getList2_(refresh); } } @@ -543,16 +553,22 @@ private: res.result(http::status::ok); res.insert("Content-Type", "application/json"); if (path == "/validators/bad") + { res.body() = "{ 'bad': \"1']"; + } else if (path == "/validators/missing") + { res.body() = "{\"version\": 1}"; + } else { int refresh = 5; constexpr char const* refreshPrefix = "/validators/refresh/"; if (boost::starts_with(path, refreshPrefix)) + { refresh = boost::lexical_cast( path.substr(strlen(refreshPrefix))); + } res.body() = getList_(refresh); } } @@ -570,8 +586,10 @@ private: { std::stringstream body; for (auto i = 0; i < 1024; ++i) + { body << static_cast(rand_int(32, 126)), res.body() = body.str(); + } } } else if (boost::starts_with(path, "/sleep/")) @@ -582,13 +600,21 @@ private: else if (boost::starts_with(path, "/redirect")) { if (boost::ends_with(path, "/301")) + { res.result(http::status::moved_permanently); + } else if (boost::ends_with(path, "/302")) + { res.result(http::status::found); + } else if (boost::ends_with(path, "/307")) + { res.result(http::status::temporary_redirect); + } else if (boost::ends_with(path, "/308")) + { res.result(http::status::permanent_redirect); + } std::stringstream location; if (boost::starts_with(path, "/redirect_to/")) @@ -630,9 +656,13 @@ private: } if (ssl) + { write(*ssl_stream, res, ec); + } else + { write(sock, res, ec); + } if (ec || req.need_eof()) break; diff --git a/src/test/jtx/amount.h b/src/test/jtx/amount.h index 7819a09451..0f6db6bdcd 100644 --- a/src/test/jtx/amount.h +++ b/src/test/jtx/amount.h @@ -120,7 +120,7 @@ public: return amount_; } - inline int + int signum() const { return amount_.signum(); @@ -257,8 +257,8 @@ struct XRP_t return xrpIssue(); } - bool - integral() const + static bool + integral() { return true; } @@ -482,11 +482,10 @@ public: MPT(std::string const& n = "") : name(n), issuanceID(noMPT()) { } - MPT(Asset const& asset) : name(""), issuanceID(asset.get()) + MPT(Asset const& asset) : issuanceID(asset.get()) { } - MPT(AccountID const& account, std::int32_t seq = 0) - : name(""), issuanceID(makeMptID(seq, account)) + MPT(AccountID const& account, std::int32_t seq = 0) : issuanceID(makeMptID(seq, account)) { } @@ -508,8 +507,8 @@ public: { return mptIssue(); } - bool - integral() const + static bool + integral() { return true; } diff --git a/src/test/jtx/mpt.h b/src/test/jtx/mpt.h index 96fbf30d90..a474c2e2c7 100644 --- a/src/test/jtx/mpt.h +++ b/src/test/jtx/mpt.h @@ -96,7 +96,7 @@ struct MPTCreate struct MPTInit { - Holders holders = {}; + Holders holders = {}; // NOLINT(readability-redundant-member-init) PrettyAmount const xrp = XRP(10'000); PrettyAmount const xrpHolders = XRP(10'000); bool fund = true; @@ -110,7 +110,7 @@ struct MPTInitDef { Env& env; Account issuer; - Holders holders = {}; + Holders holders = {}; // NOLINT(readability-redundant-member-init) std::uint16_t transferFee = 0; std::optional pay = std::nullopt; std::uint32_t flags = MPTDEXFlags; diff --git a/src/test/jtx/vault.h b/src/test/jtx/vault.h index 748d3341a5..8a21503be2 100644 --- a/src/test/jtx/vault.h +++ b/src/test/jtx/vault.h @@ -25,7 +25,8 @@ struct Vault { Account owner; Asset asset; - std::optional flags{}; + std::optional flags = + std::nullopt; // NOLINT(readability-redundant-member-init) }; /** Return a VaultCreate transaction and the Vault's expected keylet. */ @@ -75,7 +76,7 @@ struct Vault Account issuer; uint256 id; Account holder; - std::optional amount{}; + std::optional amount = std::nullopt; // NOLINT(readability-redundant-member-init) }; static Json::Value diff --git a/src/test/jtx/xchain_bridge.h b/src/test/jtx/xchain_bridge.h index 1270d03ed6..9359b3fdde 100644 --- a/src/test/jtx/xchain_bridge.h +++ b/src/test/jtx/xchain_bridge.h @@ -224,7 +224,7 @@ struct XChainBridgeObjects Account const& acc, Json::Value const& bridge = Json::nullValue, STAmount const& _reward = XRP(1), - std::optional const& minAccountCreate = std::nullopt) + std::optional const& minAccountCreate = std::nullopt) const { return bridge_create( acc, bridge == Json::nullValue ? jvb : bridge, _reward, minAccountCreate); diff --git a/src/test/nodestore/TestBase.h b/src/test/nodestore/TestBase.h index 6f29457e85..13e5b4beba 100644 --- a/src/test/nodestore/TestBase.h +++ b/src/test/nodestore/TestBase.h @@ -119,7 +119,7 @@ public: } // Store a batch in a backend - void + static void storeBatch(Backend& backend, Batch const& batch) { for (int i = 0; i < batch.size(); ++i) diff --git a/src/test/unit_test/FileDirGuard.h b/src/test/unit_test/FileDirGuard.h index b551b9389d..6b39ecd079 100644 --- a/src/test/unit_test/FileDirGuard.h +++ b/src/test/unit_test/FileDirGuard.h @@ -30,10 +30,14 @@ protected: rmDir(path const& toRm) { if (is_directory(toRm) && is_empty(toRm)) + { remove(toRm); + } else + { test_.log << "Expected " << toRm.string() << " to be an empty existing directory." << std::endl; + } } public: @@ -51,7 +55,9 @@ public: rmSubDir_ = true; } else if (is_directory(subDir_)) + { rmSubDir_ = false; + } else { // Cannot run the test. Someone created a file where we want to @@ -129,8 +135,10 @@ public: else { if (created_) + { test_.log << "Expected " << file_.string() << " to be an existing file." << std::endl; + } } } catch (std::exception& e) diff --git a/src/test/unit_test/SuiteJournal.h b/src/test/unit_test/SuiteJournal.h index 93005401e6..36a580b7ed 100644 --- a/src/test/unit_test/SuiteJournal.h +++ b/src/test/unit_test/SuiteJournal.h @@ -22,7 +22,7 @@ public: } // For unit testing, always generate logging text. - inline bool + bool active(beast::severities::Severity level) const override { return true; @@ -114,7 +114,7 @@ public: writeAlways(level, text); } - inline void + void writeAlways(beast::severities::Severity level, std::string const& text) override { strm_ << text << std::endl; diff --git a/src/xrpld/app/consensus/RCLCxPeerPos.h b/src/xrpld/app/consensus/RCLCxPeerPos.h index e334320826..f5d3f0e8f0 100644 --- a/src/xrpld/app/consensus/RCLCxPeerPos.h +++ b/src/xrpld/app/consensus/RCLCxPeerPos.h @@ -95,7 +95,7 @@ private: { using beast::hash_append; hash_append(h, HashPrefix::proposal); - hash_append(h, std::uint32_t(proposal().proposeSeq())); + hash_append(h, proposal().proposeSeq()); hash_append(h, proposal().closeTime()); hash_append(h, proposal().prevLedger()); hash_append(h, proposal().position()); diff --git a/src/xrpld/app/ledger/LedgerMaster.h b/src/xrpld/app/ledger/LedgerMaster.h index e598787047..220c04cc91 100644 --- a/src/xrpld/app/ledger/LedgerMaster.h +++ b/src/xrpld/app/ledger/LedgerMaster.h @@ -363,7 +363,7 @@ private: LedgerIndex const max_ledger_difference_{1000000}; // Time that the previous upgrade warning was issued. - TimeKeeper::time_point upgradeWarningPrevTime_{}; + TimeKeeper::time_point upgradeWarningPrevTime_; private: struct Stats diff --git a/src/xrpld/app/ledger/LedgerReplayTask.h b/src/xrpld/app/ledger/LedgerReplayTask.h index 030121b240..a1fadc95ff 100644 --- a/src/xrpld/app/ledger/LedgerReplayTask.h +++ b/src/xrpld/app/ledger/LedgerReplayTask.h @@ -31,8 +31,8 @@ public: // to be updated std::uint32_t finishSeq_ = 0; - std::vector skipList_ = {}; // including the finishHash - uint256 startHash_ = {}; + std::vector skipList_; // including the finishHash + uint256 startHash_; std::uint32_t startSeq_ = 0; bool full_ = false; @@ -146,7 +146,7 @@ private: TaskParameter parameter_; uint32_t maxTimeouts_; std::shared_ptr skipListAcquirer_; - std::shared_ptr parent_ = {}; + std::shared_ptr parent_; uint32_t deltaToBuild_ = 0; // should not build until have parent std::vector> deltas_; diff --git a/src/xrpld/app/ledger/LedgerToJson.h b/src/xrpld/app/ledger/LedgerToJson.h index 3686311656..53985f343b 100644 --- a/src/xrpld/app/ledger/LedgerToJson.h +++ b/src/xrpld/app/ledger/LedgerToJson.h @@ -19,7 +19,7 @@ struct LedgerFill std::vector q = {}) : ledger(l), options(o), txQueue(std::move(q)), context(ctx) { - if (context) + if (context != nullptr) closeTime = context->ledgerMaster.getCloseTimeBySeq(ledger.seq()); } diff --git a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h index 9ac58c2e7c..6839c44386 100644 --- a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h +++ b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h @@ -125,8 +125,8 @@ private: InboundLedgers& inboundLedgers_; std::uint32_t const ledgerSeq_; std::unique_ptr peerSet_; - std::shared_ptr replayTemp_ = {}; - std::shared_ptr fullLedger_ = {}; + std::shared_ptr replayTemp_; + std::shared_ptr fullLedger_; std::map> orderedTxns_; std::vector dataReadyCallbacks_; std::set reasons_; diff --git a/src/xrpld/app/misc/SHAMapStoreImp.h b/src/xrpld/app/misc/SHAMapStoreImp.h index c361fa426c..08e3dd70eb 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.h +++ b/src/xrpld/app/misc/SHAMapStoreImp.h @@ -61,7 +61,7 @@ private: // minimum # of ledgers required for standalone mode. static std::uint32_t const minimumDeletionIntervalSA_ = 8; // minimum ledger to maintain online. - std::atomic minimumOnline_{}; + std::atomic minimumOnline_; NodeStore::Scheduler& scheduler_; beast::Journal const journal_; @@ -102,7 +102,7 @@ public: std::uint32_t clampFetchDepth(std::uint32_t fetch_depth) const override { - return deleteInterval_ ? std::min(fetch_depth, deleteInterval_) : fetch_depth; + return (deleteInterval_ != 0u) ? std::min(fetch_depth, deleteInterval_) : fetch_depth; } std::unique_ptr @@ -209,7 +209,7 @@ public: void start() override { - if (deleteInterval_) + if (deleteInterval_ != 0u) thread_ = std::thread(&SHAMapStoreImp::run, this); } diff --git a/src/xrpld/app/misc/Transaction.h b/src/xrpld/app/misc/Transaction.h index 5fe8dcf4fa..31d899d99b 100644 --- a/src/xrpld/app/misc/Transaction.h +++ b/src/xrpld/app/misc/Transaction.h @@ -138,7 +138,7 @@ public: * @return Whether transaction is being applied within a batch. */ bool - getApplying() + getApplying() const { // Note that all access to mApplying are made by NetworkOPsImp, and must // be done under that class's lock. @@ -307,7 +307,7 @@ public: // Calling the wrong getter function will throw an exception. // See documentation for the getter functions for more details bool - isFound() + isFound() const { return std::holds_alternative>(locator); } diff --git a/src/xrpld/app/misc/TxQ.h b/src/xrpld/app/misc/TxQ.h index b9ea7cc8f6..49a29802bb 100644 --- a/src/xrpld/app/misc/TxQ.h +++ b/src/xrpld/app/misc/TxQ.h @@ -382,11 +382,12 @@ private: , targetTxnCount_( setup.targetTxnInLedger < minimumTxnCount_ ? minimumTxnCount_ : setup.targetTxnInLedger) - , maximumTxnCount_( - setup.maximumTxnInLedger ? *setup.maximumTxnInLedger < targetTxnCount_ - ? targetTxnCount_ - : *setup.maximumTxnInLedger - : std::optional(std::nullopt)) + , maximumTxnCount_([&]() -> std::optional { + if (!setup.maximumTxnInLedger) + return std::nullopt; + return *setup.maximumTxnInLedger < targetTxnCount_ ? targetTxnCount_ + : *setup.maximumTxnInLedger; + }()) , txnsExpected_(minimumTxnCount_) , recentTxnCounts_(setup.ledgersInQueue) , escalationMultiplier_(setup.minimumEscalationMultiplier) @@ -672,7 +673,7 @@ private: bool empty() const { - return !getTxnCount(); + return getTxnCount() == 0u; } /// Find the entry in transactions that precedes seqProx, if one does. diff --git a/src/xrpld/app/misc/detail/WorkBase.h b/src/xrpld/app/misc/detail/WorkBase.h index 825866ee9b..20a4987bc4 100644 --- a/src/xrpld/app/misc/detail/WorkBase.h +++ b/src/xrpld/app/misc/detail/WorkBase.h @@ -134,10 +134,12 @@ void WorkBase::run() { if (!strand_.running_in_this_thread()) + { return boost::asio::post( ios_, boost::asio::bind_executor( strand_, std::bind(&WorkBase::run, impl().shared_from_this()))); + } resolver_.async_resolve( host_, diff --git a/src/xrpld/app/misc/detail/WorkFile.h b/src/xrpld/app/misc/detail/WorkFile.h index 5113ec5f3a..06cca0f835 100644 --- a/src/xrpld/app/misc/detail/WorkFile.h +++ b/src/xrpld/app/misc/detail/WorkFile.h @@ -59,9 +59,12 @@ inline void WorkFile::run() { if (!strand_.running_in_this_thread()) - return boost::asio::post( + { + boost::asio::post( ios_, boost::asio::bind_executor(strand_, std::bind(&WorkFile::run, shared_from_this()))); + return; + } error_code ec; auto const fileContents = getFileContents(ec, path_, megabytes(1)); diff --git a/src/xrpld/app/misc/detail/WorkPlain.h b/src/xrpld/app/misc/detail/WorkPlain.h index 361a7b4513..fbbc323193 100644 --- a/src/xrpld/app/misc/detail/WorkPlain.h +++ b/src/xrpld/app/misc/detail/WorkPlain.h @@ -51,7 +51,10 @@ inline void WorkPlain::onConnect(error_code const& ec) { if (ec) - return fail(ec); + { + fail(ec); + return; + } onStart(); } diff --git a/src/xrpld/consensus/Consensus.h b/src/xrpld/consensus/Consensus.h index 142b1a01f0..4337e8da01 100644 --- a/src/xrpld/consensus/Consensus.h +++ b/src/xrpld/consensus/Consensus.h @@ -779,9 +779,13 @@ Consensus::peerProposalInternal( } if (peerPosIt != currPeerPositions_.end()) + { peerPosIt->second = newPeerPos; + } else + { currPeerPositions_.emplace(peerID, newPeerPos); + } } if (newPeerProp.isInitial()) @@ -803,7 +807,9 @@ Consensus::peerProposalInternal( // spawn a request for it and return nullopt/nullptr. It will call // gotTxSet once it arrives if (auto set = adaptor_.acquireTxSet(newPeerProp.position())) + { gotTxSet(now_, *set); + } else JLOG(j_.debug()) << "Don't have tx set for peer"; } @@ -843,9 +849,13 @@ Consensus::timerEntry( } if (phase_ == ConsensusPhase::open) + { phaseOpen(clog); + } else if (phase_ == ConsensusPhase::establish) + { phaseEstablish(clog); + } CLOG(clog) << "timerEntry finishing in phase " << to_string(phase_) << ". "; } @@ -932,7 +942,9 @@ Consensus::getJson(bool full) const ret["close_granularity"] = static_cast(closeResolution_.count()); } else + { ret["synched"] = false; + } ret["phase"] = to_string(phase_); @@ -1137,9 +1149,13 @@ Consensus::phaseOpen(std::unique_ptr const& clog) : prevCloseTime_; // use the time we saw internally if (now_ >= lastCloseTime) + { sinceClose = duration_cast(now_ - lastCloseTime); + } else + { sinceClose = -duration_cast(lastCloseTime - now_); + } CLOG(clog) << "calculating how long since last ledger's close time " "based on mode : " << to_string(mode) << ", previous closeAgree: " << closeAgree @@ -1201,7 +1217,7 @@ Consensus::shouldPause(std::unique_ptr const& clog) << "offline: " << offline << ", " << "quorum: " << quorum << ")"; - if (!ahead || !laggards || !totalValidators || !adaptor_.validator() || + if ((ahead == 0u) || (laggards == 0u) || (totalValidators == 0u) || !adaptor_.validator() || !adaptor_.haveValidated() || result_->roundTime.read() > parms.ledgerMAX_CONSENSUS) { j_.debug() << "not pausing (early)" << vars.str(); diff --git a/src/xrpld/consensus/DisputedTx.h b/src/xrpld/consensus/DisputedTx.h index e8304f4242..2cfbedf7f1 100644 --- a/src/xrpld/consensus/DisputedTx.h +++ b/src/xrpld/consensus/DisputedTx.h @@ -98,9 +98,11 @@ public: // Compute the percentage of nodes voting 'yes' (possibly including us) int const support = (yays_ + (proposing && ourVote_ ? 1 : 0)) * 100; int const total = nays_ + yays_ + (proposing ? 1 : 0); - if (!total) + if (total == 0) + { // There are no votes, so we know nothing return false; + } int const weight = support / total; // Returns true if the tx has more than minCONSENSUS_PCT (80) percent // agreement. Either voting for _or_ voting against the tx. @@ -210,7 +212,7 @@ DisputedTx::setVote(NodeID_t const& peer, bool votesYes) return true; } // changes vote to yes - else if (votesYes && !it->second) + if (votesYes && !it->second) { JLOG(j_.debug()) << "Peer " << peer << " now votes YES on " << tx_.id(); --nays_; @@ -219,7 +221,7 @@ DisputedTx::setVote(NodeID_t const& peer, bool votesYes) return true; } // changes vote to no - else if (!votesYes && it->second) + if (!votesYes && it->second) { JLOG(j_.debug()) << "Peer " << peer << " now votes NO on " << tx_.id(); ++nays_; @@ -240,9 +242,13 @@ DisputedTx::unVote(NodeID_t const& peer) if (it != votes_.end()) { if (it->second) + { --yays_; + } else + { --nays_; + } votes_.erase(it); } diff --git a/src/xrpld/consensus/LedgerTrie.h b/src/xrpld/consensus/LedgerTrie.h index aecd105c07..f042853712 100644 --- a/src/xrpld/consensus/LedgerTrie.h +++ b/src/xrpld/consensus/LedgerTrie.h @@ -383,7 +383,7 @@ class LedgerTrie Node* findByLedgerID(Ledger const& ledger, Node* parent = nullptr) const { - if (!parent) + if (parent == nullptr) parent = root.get(); if (ledger.id() == parent->span.tip().id) return parent; @@ -513,7 +513,7 @@ public: { Node* loc = findByLedgerID(ledger); // Must be exact match with tip support - if (!loc || loc->tipSupport == 0) + if ((loc == nullptr) || loc->tipSupport == 0) return false; // found our node, remove it @@ -553,7 +553,9 @@ public: parent->erase(loc); } else + { break; + } loc = parent; } return true; @@ -582,7 +584,7 @@ public: branchSupport(Ledger const& ledger) const { Node const* loc = findByLedgerID(ledger); - if (!loc) + if (loc == nullptr) { Seq diffSeq; std::tie(loc, diffSeq) = find(ledger); @@ -692,8 +694,10 @@ public: uncommitted += uncommittedIt->second; uncommittedIt++; } - else // otherwise we jump to the end of the span + else + { // otherwise we jump to the end of the span nextSeq = curr->span.end(); + } } // We did not consume the entire span, so we have found the // preferred ledger @@ -736,9 +740,13 @@ public: // If the best child has margin exceeding the uncommitted support, // continue from that child, otherwise we are done if (best && ((margin > uncommitted) || (uncommitted == 0))) + { curr = best; - else // current is the best + } + else + { // current is the best done = true; + } } return curr->span.tip(); } @@ -785,7 +793,7 @@ public: { Node const* curr = nodes.top(); nodes.pop(); - if (!curr) + if (curr == nullptr) continue; // Node with 0 tip support must have multiple children diff --git a/src/xrpld/consensus/Validations.h b/src/xrpld/consensus/Validations.h index 4d0b64a350..00f10f89cf 100644 --- a/src/xrpld/consensus/Validations.h +++ b/src/xrpld/consensus/Validations.h @@ -369,7 +369,9 @@ private: it = acquiring_.erase(it); } else + { ++it; + } } } @@ -431,9 +433,13 @@ private: else { if (std::optional ledger = adaptor_.acquire(val.ledgerID())) + { updateTrie(lock, nodeID, *ledger); + } else + { acquiring_[valPair].insert(nodeID); + } } } @@ -654,7 +660,9 @@ public: updateTrie(lock, nodeID, val, old); } else + { return ValStatus::stale; + } } else if (val.trusted()) { @@ -917,9 +925,11 @@ public: // Use trie if ledger is the right one if (ledger.id() == ledgerID) + { return withTrie(lock, [&ledger](LedgerTrie& trie) { return trie.branchSupport(ledger) - trie.tipSupport(ledger); }); + } // Count parent ledgers as fallback return std::count_if(lastLedger_.begin(), lastLedger_.end(), [&ledgerID](auto const& it) { @@ -1028,9 +1038,13 @@ public: { std::optional loadFee = v.loadFee(); if (loadFee) + { res.push_back(*loadFee); + } else + { res.push_back(baseFee); + } } }); return res; diff --git a/src/xrpld/core/TimeKeeper.h b/src/xrpld/core/TimeKeeper.h index 0d809d076d..83c0d81d60 100644 --- a/src/xrpld/core/TimeKeeper.h +++ b/src/xrpld/core/TimeKeeper.h @@ -11,7 +11,7 @@ namespace xrpl { class TimeKeeper : public beast::abstract_clock { private: - std::atomic closeOffset_{}; + std::atomic closeOffset_; // Adjust system_clock::time_point for NetClock epoch static constexpr time_point diff --git a/src/xrpld/overlay/ClusterNode.h b/src/xrpld/overlay/ClusterNode.h index c6ab208383..8a8a8bf052 100644 --- a/src/xrpld/overlay/ClusterNode.h +++ b/src/xrpld/overlay/ClusterNode.h @@ -50,7 +50,7 @@ private: PublicKey const identity_; std::string name_; std::uint32_t mLoadFee = 0; - NetClock::time_point mReportTime = {}; + NetClock::time_point mReportTime; }; } // namespace xrpl diff --git a/src/xrpld/overlay/Compression.h b/src/xrpld/overlay/Compression.h index 784e7c1607..9c4e84f317 100644 --- a/src/xrpld/overlay/Compression.h +++ b/src/xrpld/overlay/Compression.h @@ -36,18 +36,18 @@ decompress( try { if (algorithm == Algorithm::LZ4) + { return xrpl::compression_algorithms::lz4Decompress( in, inSize, decompressed, decompressedSize); - else - { - // LCOV_EXCL_START - JLOG(debugLog().warn()) - << "decompress: invalid compression algorithm " << static_cast(algorithm); - UNREACHABLE( - "xrpl::compression::decompress : invalid compression " - "algorithm"); - // LCOV_EXCL_STOP } + + // LCOV_EXCL_START + JLOG(debugLog().warn()) << "decompress: invalid compression algorithm " + << static_cast(algorithm); + UNREACHABLE( + "xrpl::compression::decompress : invalid compression " + "algorithm"); + // LCOV_EXCL_STOP } catch (...) // NOLINT(bugprone-empty-catch) { @@ -75,18 +75,18 @@ compress( try { if (algorithm == Algorithm::LZ4) + { return xrpl::compression_algorithms::lz4Compress( in, inSize, std::forward(bf)); - else - { - // LCOV_EXCL_START - JLOG(debugLog().warn()) - << "compress: invalid compression algorithm" << static_cast(algorithm); - UNREACHABLE( - "xrpl::compression::compress : invalid compression " - "algorithm"); - // LCOV_EXCL_STOP } + + // LCOV_EXCL_START + JLOG(debugLog().warn()) << "compress: invalid compression algorithm" + << static_cast(algorithm); + UNREACHABLE( + "xrpl::compression::compress : invalid compression " + "algorithm"); + // LCOV_EXCL_STOP } catch (...) // NOLINT(bugprone-empty-catch) { diff --git a/src/xrpld/overlay/Slot.h b/src/xrpld/overlay/Slot.h index 22e908ee99..f287ea46fc 100644 --- a/src/xrpld/overlay/Slot.h +++ b/src/xrpld/overlay/Slot.h @@ -324,7 +324,7 @@ Slot::update( // idled peers. std::unordered_set selected; auto const consideredPoolSize = considered_.size(); - while (selected.size() != maxSelectedPeers_ && considered_.size() != 0) + while (selected.size() != maxSelectedPeers_ && !considered_.empty()) { auto i = considered_.size() == 1 ? 0 : rand_int(considered_.size() - 1); auto it = std::next(considered_.begin(), i); @@ -366,7 +366,9 @@ Slot::update( v.count = 0; if (selected.find(k) != selected.end()) + { v.state = PeerState::Selected; + } else if (v.state != PeerState::Squelched) { if (journal_.trace()) @@ -411,7 +413,7 @@ Slot::deletePeer(PublicKey const& validator, id_t id, bool erase) JLOG(journal_.trace()) << "deletePeer: " << Slice(validator) << " " << id << " selected " << (it->second.state == PeerState::Selected) << " considered " - << (considered_.find(id) != considered_.end()) << " erase " << erase; + << (considered_.contains(id)) << " erase " << erase; auto now = clock_type::now(); if (it->second.state == PeerState::Selected) { @@ -428,7 +430,7 @@ Slot::deletePeer(PublicKey const& validator, id_t id, bool erase) reachedThreshold_ = 0; state_ = SlotState::Counting; } - else if (considered_.find(id) != considered_.end()) + else if (considered_.contains(id)) { if (it->second.count > MAX_MESSAGE_THRESHOLD) --reachedThreshold_; @@ -490,8 +492,10 @@ Slot::getSelected() const { std::set r; for (auto const& [id, info] : peers_) + { if (info.state == PeerState::Selected) r.insert(id); + } return r; } @@ -504,6 +508,7 @@ Slot::getPeers() const unordered_map>(); for (auto const& [id, info] : peers_) + { r.emplace( std::make_pair( id, @@ -513,6 +518,7 @@ Slot::getPeers() const info.count, epoch(info.expire).count(), epoch(info.lastMessage).count())))); + } return r; } @@ -560,8 +566,10 @@ public: reduceRelayReady() { if (!reduceRelayReady_) + { reduceRelayReady_ = reduce_relay::epoch(clock_type::now()) > reduce_relay::WAIT_ON_BOOTUP; + } return reduceRelayReady_; } @@ -756,7 +764,9 @@ Slots::updateSlotAndSquelch( it->second.update(validator, id, type, callback); } else + { it->second.update(validator, id, type, callback); + } } template @@ -782,7 +792,9 @@ Slots::deleteIdlePeers() it = slots_.erase(it); } else + { ++it; + } } } diff --git a/src/xrpld/overlay/Squelch.h b/src/xrpld/overlay/Squelch.h index 1d92cfed3a..32f429aa10 100644 --- a/src/xrpld/overlay/Squelch.h +++ b/src/xrpld/overlay/Squelch.h @@ -89,7 +89,7 @@ Squelch::expireSquelch(PublicKey const& validator) auto const& it = squelched_.find(validator); if (it == squelched_.end()) return true; - else if (it->second > now) + if (it->second > now) return false; // squelch expired diff --git a/src/xrpld/overlay/detail/PeerImp.h b/src/xrpld/overlay/detail/PeerImp.h index 7f7d8c9324..325dca6430 100644 --- a/src/xrpld/overlay/detail/PeerImp.h +++ b/src/xrpld/overlay/detail/PeerImp.h @@ -190,7 +190,7 @@ private: struct ChargeWithContext { Resource::Charge fee = Resource::feeTrivialPeer; - std::string context = {}; + std::string context{}; // NOLINT(readability-redundant-member-init) void update(Resource::Charge f, std::string const& add) diff --git a/src/xrpld/overlay/detail/PeerReservationTable.cpp b/src/xrpld/overlay/detail/PeerReservationTable.cpp index 6ea2253df9..51a1a10299 100644 --- a/src/xrpld/overlay/detail/PeerReservationTable.cpp +++ b/src/xrpld/overlay/detail/PeerReservationTable.cpp @@ -98,7 +98,7 @@ PeerReservationTable::erase(PublicKey const& nodeId) std::lock_guard const lock(mutex_); - auto const it = table_.find({nodeId}); + auto const it = table_.find({.nodeId = nodeId}); if (it != table_.end()) { previous = *it; diff --git a/src/xrpld/overlay/detail/ProtocolMessage.h b/src/xrpld/overlay/detail/ProtocolMessage.h index 41d42674ba..87098fb331 100644 --- a/src/xrpld/overlay/detail/ProtocolMessage.h +++ b/src/xrpld/overlay/detail/ProtocolMessage.h @@ -258,7 +258,9 @@ parseMessageContent(MessageHeader const& header, Buffers const& buffers) return {}; } else if (!m->ParseFromZeroCopyStream(&stream)) + { return {}; + } return m; } diff --git a/src/xrpld/overlay/detail/ProtocolVersion.h b/src/xrpld/overlay/detail/ProtocolVersion.h index 5b3a1b3302..c4fa7ced0b 100644 --- a/src/xrpld/overlay/detail/ProtocolVersion.h +++ b/src/xrpld/overlay/detail/ProtocolVersion.h @@ -17,7 +17,7 @@ namespace xrpl { * */ using ProtocolVersion = std::pair; -inline constexpr ProtocolVersion +constexpr ProtocolVersion make_protocol(std::uint16_t major, std::uint16_t minor) { return {major, minor}; diff --git a/src/xrpld/overlay/detail/TrafficCount.h b/src/xrpld/overlay/detail/TrafficCount.h index 930e92129d..bdc0729a51 100644 --- a/src/xrpld/overlay/detail/TrafficCount.h +++ b/src/xrpld/overlay/detail/TrafficCount.h @@ -56,7 +56,7 @@ public: operator bool() const { - return messagesIn || messagesOut; + return (messagesIn != 0u) || (messagesOut != 0u); } }; diff --git a/src/xrpld/overlay/predicates.h b/src/xrpld/overlay/predicates.h index 3adecf7c6a..e0b4a626ec 100644 --- a/src/xrpld/overlay/predicates.h +++ b/src/xrpld/overlay/predicates.h @@ -101,10 +101,7 @@ struct match_peer bool operator()(std::shared_ptr const& peer) const { - if (matchPeer && (peer.get() == matchPeer)) - return true; - - return false; + return (matchPeer != nullptr) && (peer.get() == matchPeer); } }; @@ -146,10 +143,7 @@ struct peer_in_set bool operator()(std::shared_ptr const& peer) const { - if (peerSet.count(peer->id()) == 0) - return false; - - return true; + return peerSet.contains(peer->id()); } }; diff --git a/src/xrpld/peerfinder/detail/Bootcache.h b/src/xrpld/peerfinder/detail/Bootcache.h index 9ab0a878e8..a552c2f040 100644 --- a/src/xrpld/peerfinder/detail/Bootcache.h +++ b/src/xrpld/peerfinder/detail/Bootcache.h @@ -55,9 +55,7 @@ private: friend bool operator<(Entry const& lhs, Entry const& rhs) { - if (lhs.valence() > rhs.valence()) - return true; - return false; + return lhs.valence() > rhs.valence(); } private: diff --git a/src/xrpld/peerfinder/detail/Counts.h b/src/xrpld/peerfinder/detail/Counts.h index 8d40b44300..4b52453708 100644 --- a/src/xrpld/peerfinder/detail/Counts.h +++ b/src/xrpld/peerfinder/detail/Counts.h @@ -179,15 +179,12 @@ public: // // Fixed peers do not count towards the active outgoing total. - if (m_out_max > 0) - return false; - - return true; + return m_out_max <= 0; } /** Output statistics. */ void - onWrite(beast::PropertyStream::Map& map) + onWrite(beast::PropertyStream::Map& map) const { map["accept"] = acceptCount(); map["connect"] = connectCount(); @@ -243,9 +240,13 @@ private: if (!s.fixed() && !s.reserved()) { if (s.inbound()) + { m_in_active += n; + } else + { m_out_active += n; + } } m_active += n; break; diff --git a/src/xrpld/peerfinder/detail/Livecache.h b/src/xrpld/peerfinder/detail/Livecache.h index ac435e1e24..a9a641027f 100644 --- a/src/xrpld/peerfinder/detail/Livecache.h +++ b/src/xrpld/peerfinder/detail/Livecache.h @@ -409,7 +409,7 @@ Livecache::insert(Endpoint const& ep) << " at hops " << ep.hops; return; } - else if (!result.second && (ep.hops > e.endpoint.hops)) + if (!result.second && (ep.hops > e.endpoint.hops)) { // Drop duplicates at higher hops std::size_t const excess(ep.hops - e.endpoint.hops); diff --git a/src/xrpld/peerfinder/detail/Logic.h b/src/xrpld/peerfinder/detail/Logic.h index ad0a2f8b96..8d60b49273 100644 --- a/src/xrpld/peerfinder/detail/Logic.h +++ b/src/xrpld/peerfinder/detail/Logic.h @@ -254,7 +254,7 @@ public: } // Check for duplicate connection - if (slots_.find(remote_endpoint) != slots_.end()) + if (slots_.contains(remote_endpoint)) { JLOG(m_journal.debug()) << beast::leftw(18) << "Logic dropping " << remote_endpoint << " as duplicate incoming"; @@ -290,7 +290,7 @@ public: std::lock_guard const _(lock_); // Check for duplicate connection - if (slots_.find(remote_endpoint) != slots_.end()) + if (slots_.contains(remote_endpoint)) { JLOG(m_journal.debug()) << beast::leftw(18) << "Logic dropping " << remote_endpoint << " as duplicate connect"; @@ -377,7 +377,7 @@ public: "xrpl::PeerFinder::Logic::activate : valid slot state"); // Check for duplicate connection by key - if (keys_.find(key) != keys_.end()) + if (keys_.contains(key)) return Result::duplicatePeer; // If the peer belongs to a cluster or is reserved, @@ -418,9 +418,11 @@ public: { auto iter(fixed_.find(slot->remote_endpoint())); if (iter == fixed_.end()) + { LogicError( "PeerFinder::Logic::activate(): remote_endpoint " "missing from fixed_"); + } iter->second.success(m_clock.now()); JLOG(journal.trace()) << "Logic fixed success"; @@ -516,7 +518,7 @@ public: << ((h.list().size() > 1) ? "endpoints" : "endpoint"); return h.list(); } - else if (counts_.attempts() > 0) + if (counts_.attempts() > 0) { JLOG(m_journal.debug()) << beast::leftw(18) << "Logic waiting on " << counts_.attempts() << " attempts"; @@ -825,9 +827,11 @@ public: auto const iter = slots_.find(slot->remote_endpoint()); // The slot must exist in the table if (iter == slots_.end()) + { LogicError( "PeerFinder::Logic::remove(): remote_endpoint " "missing from slots_"); + } // Remove from slot by IP table slots_.erase(iter); @@ -838,9 +842,11 @@ public: auto const iter = keys_.find(*slot->public_key()); // Key must exist if (iter == keys_.end()) + { LogicError( "PeerFinder::Logic::remove(): public_key missing " "from keys_"); + } keys_.erase(iter); } @@ -849,9 +855,11 @@ public: auto const iter(connectedAddresses_.find(slot->remote_endpoint().address())); // Address must exist if (iter == connectedAddresses_.end()) + { LogicError( "PeerFinder::Logic::remove(): remote_endpoint " "address missing from connectedAddresses_"); + } connectedAddresses_.erase(iter); } @@ -875,9 +883,11 @@ public: { auto iter(fixed_.find(slot->remote_endpoint())); if (iter == fixed_.end()) + { LogicError( "PeerFinder::Logic::on_closed(): remote_endpoint " "missing from fixed_"); + } iter->second.failure(m_clock.now()); JLOG(journal.debug()) << "Logic fixed failed"; @@ -939,8 +949,10 @@ public: fixed(beast::IP::Endpoint const& endpoint) const { for (auto const& entry : fixed_) + { if (entry.first == endpoint) return true; + } return false; } @@ -951,8 +963,10 @@ public: fixed(beast::IP::Address const& address) const { for (auto const& entry : fixed_) + { if (entry.first.address() == address) return true; + } return false; } diff --git a/src/xrpld/rpc/BookChanges.h b/src/xrpld/rpc/BookChanges.h index 41853ee890..89b99cabe3 100644 --- a/src/xrpld/rpc/BookChanges.h +++ b/src/xrpld/rpc/BookChanges.h @@ -102,7 +102,7 @@ computeBookChanges(std::shared_ptr const& lpAccepted) std::string const g{to_string(deltaGets.asset())}; std::string const p{to_string(deltaPays.asset())}; - bool const noswap = isXRP(deltaGets) ? true : (isXRP(deltaPays) ? false : (g < p)); + bool const noswap = isXRP(deltaGets) || (!isXRP(deltaPays) && (g < p)); STAmount first = noswap ? deltaGets : deltaPays; STAmount second = noswap ? deltaPays : deltaGets; @@ -121,15 +121,20 @@ computeBookChanges(std::shared_ptr const& lpAccepted) std::stringstream ss; if (noswap) + { ss << g << "|" << p; + } else + { ss << p << "|" << g; + } std::optional const domain = finalFields[~sfDomainID]; std::string const key{ss.str()}; - if (tally.find(key) == tally.end()) + if (!tally.contains(key)) + { tally[key] = { first, // side A vol second, // side B vol @@ -138,6 +143,7 @@ computeBookChanges(std::shared_ptr const& lpAccepted) rate, // open rate, // close domain}; + } else { // increment volume diff --git a/src/xrpld/rpc/Context.h b/src/xrpld/rpc/Context.h index e77d9adeb3..58768d028a 100644 --- a/src/xrpld/rpc/Context.h +++ b/src/xrpld/rpc/Context.h @@ -24,8 +24,8 @@ struct Context LedgerMaster& ledgerMaster; Resource::Consumer& consumer; Role role; - std::shared_ptr coro{}; - InfoSub::pointer infoSub{}; + std::shared_ptr coro; + InfoSub::pointer infoSub; unsigned int apiVersion; }; diff --git a/src/xrpld/rpc/Status.h b/src/xrpld/rpc/Status.h index 418ad9ccae..c7c9eed63e 100644 --- a/src/xrpld/rpc/Status.h +++ b/src/xrpld/rpc/Status.h @@ -93,9 +93,13 @@ public: if (auto ec = toErrorCode()) { if (messages_.empty()) + { inject_error(ec, object); + } else + { inject_error(ec, message(), object); + } } } diff --git a/src/xrpld/rpc/detail/TrustLine.h b/src/xrpld/rpc/detail/TrustLine.h index a0fce8847a..f3bf397400 100644 --- a/src/xrpld/rpc/detail/TrustLine.h +++ b/src/xrpld/rpc/detail/TrustLine.h @@ -69,25 +69,25 @@ public: bool getAuth() const { - return mFlags & (mViewLowest ? lsfLowAuth : lsfHighAuth); + return (mFlags & (mViewLowest ? lsfLowAuth : lsfHighAuth)) != 0u; } bool getAuthPeer() const { - return mFlags & (!mViewLowest ? lsfLowAuth : lsfHighAuth); + return (mFlags & (!mViewLowest ? lsfLowAuth : lsfHighAuth)) != 0u; } bool getNoRipple() const { - return mFlags & (mViewLowest ? lsfLowNoRipple : lsfHighNoRipple); + return (mFlags & (mViewLowest ? lsfLowNoRipple : lsfHighNoRipple)) != 0u; } bool getNoRipplePeer() const { - return mFlags & (!mViewLowest ? lsfLowNoRipple : lsfHighNoRipple); + return (mFlags & (!mViewLowest ? lsfLowNoRipple : lsfHighNoRipple)) != 0u; } LineDirection @@ -106,28 +106,28 @@ public: bool getFreeze() const { - return mFlags & (mViewLowest ? lsfLowFreeze : lsfHighFreeze); + return (mFlags & (mViewLowest ? lsfLowFreeze : lsfHighFreeze)) != 0u; } /** Have we set the deep freeze flag on our peer */ bool getDeepFreeze() const { - return mFlags & (mViewLowest ? lsfLowDeepFreeze : lsfHighDeepFreeze); + return (mFlags & (mViewLowest ? lsfLowDeepFreeze : lsfHighDeepFreeze)) != 0u; } /** Has the peer set the freeze flag on us */ bool getFreezePeer() const { - return mFlags & (!mViewLowest ? lsfLowFreeze : lsfHighFreeze); + return (mFlags & (!mViewLowest ? lsfLowFreeze : lsfHighFreeze)) != 0u; } /** Has the peer set the deep freeze flag on us */ bool getDeepFreezePeer() const { - return mFlags & (!mViewLowest ? lsfLowDeepFreeze : lsfHighDeepFreeze); + return (mFlags & (!mViewLowest ? lsfLowDeepFreeze : lsfHighDeepFreeze)) != 0u; } STAmount const& diff --git a/src/xrpld/rpc/detail/Tuning.h b/src/xrpld/rpc/detail/Tuning.h index b3b7468731..59994b1660 100644 --- a/src/xrpld/rpc/detail/Tuning.h +++ b/src/xrpld/rpc/detail/Tuning.h @@ -55,7 +55,7 @@ static int constexpr binaryPageLength = 2048; static int constexpr jsonPageLength = 256; /** Maximum number of pages in a LedgerData response. */ -inline int constexpr pageLength(bool isBinary) +int constexpr pageLength(bool isBinary) { return isBinary ? binaryPageLength : jsonPageLength; } diff --git a/src/xrpld/rpc/handlers/server_info/Version.h b/src/xrpld/rpc/handlers/server_info/Version.h index a03212e906..cda47792e8 100644 --- a/src/xrpld/rpc/handlers/server_info/Version.h +++ b/src/xrpld/rpc/handlers/server_info/Version.h @@ -13,14 +13,14 @@ public: { } - Status + static Status check() { return Status::OK; } void - writeResult(Json::Value& obj) + writeResult(Json::Value& obj) const { setVersion(obj, apiVersion_, betaEnabled_); } diff --git a/src/xrpld/rpc/json_body.h b/src/xrpld/rpc/json_body.h index d70fafb2d4..2e9e774992 100644 --- a/src/xrpld/rpc/json_body.h +++ b/src/xrpld/rpc/json_body.h @@ -69,7 +69,7 @@ struct json_body { } - void + static void init(boost::beast::error_code& ec) { ec.assign(0, ec.category());