From 1c6cdc653c5febbbfed7cec5a1e4a4336b7f4be0 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 22 Apr 2026 13:42:15 -0400 Subject: [PATCH] fix: More clang-tidy issues (#6992) --- include/xrpl/basics/SlabAllocator.h | 2 +- include/xrpl/basics/hardened_hash.h | 6 ++---- include/xrpl/basics/partitioned_unordered_map.h | 4 ++-- include/xrpl/beast/core/LockFreeStack.h | 6 ++---- include/xrpl/core/ClosureCounter.h | 2 +- include/xrpl/ledger/detail/ReadViewFwdRange.h | 2 +- include/xrpl/protocol/KnownFormats.h | 6 +++--- include/xrpl/protocol/STBitString.h | 2 +- include/xrpl/rdb/DatabaseCon.h | 2 +- include/xrpl/tx/SignerEntries.h | 6 +++--- include/xrpl/tx/applySteps.h | 2 +- src/libxrpl/ledger/PaymentSandbox.cpp | 1 + src/libxrpl/ledger/helpers/CredentialHelpers.cpp | 1 + src/libxrpl/tx/transactors/account/SignerListSet.cpp | 5 +---- src/libxrpl/tx/transactors/delegate/DelegateSet.cpp | 1 + src/libxrpl/tx/transactors/nft/NFTokenMint.cpp | 1 + src/test/app/PayChan_test.cpp | 1 - src/xrpld/app/misc/TxQ.h | 2 +- src/xrpld/app/misc/detail/ValidatorList.cpp | 1 + 19 files changed, 25 insertions(+), 28 deletions(-) diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index 094f7a0f34..5cc17858e2 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -284,7 +284,7 @@ class SlabAllocatorSet { private: // The list of allocators that belong to this set - boost::container::static_vector, 64> allocators_; + boost::container::static_vector, 64> allocators_{}; std::size_t maxSize_ = 0; diff --git a/include/xrpl/basics/hardened_hash.h b/include/xrpl/basics/hardened_hash.h index 05e6ab417f..3ff14c22c8 100644 --- a/include/xrpl/basics/hardened_hash.h +++ b/include/xrpl/basics/hardened_hash.h @@ -72,14 +72,12 @@ template class hardened_hash { private: - detail::seed_pair m_seeds; + detail::seed_pair m_seeds{detail::make_seed_pair<>()}; public: using result_type = typename HashAlgorithm::result_type; - hardened_hash() : m_seeds(detail::make_seed_pair<>()) - { - } + hardened_hash() = default; template result_type diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index 8af9341315..33fe63e91b 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -57,7 +57,7 @@ public: { using iterator_category = std::forward_iterator_tag; partition_map_type* map_{nullptr}; - typename partition_map_type::iterator ait_; + typename partition_map_type::iterator ait_{}; typename map_type::iterator mit_; iterator() = default; @@ -126,7 +126,7 @@ public: using iterator_category = std::forward_iterator_tag; partition_map_type* map_{nullptr}; - typename partition_map_type::iterator ait_; + typename partition_map_type::iterator ait_{}; typename map_type::iterator mit_; const_iterator() = default; diff --git a/include/xrpl/beast/core/LockFreeStack.h b/include/xrpl/beast/core/LockFreeStack.h index b1e911a7c5..2c03e58f68 100644 --- a/include/xrpl/beast/core/LockFreeStack.h +++ b/include/xrpl/beast/core/LockFreeStack.h @@ -24,9 +24,7 @@ public: using reference = std:: conditional_t; - LockFreeStackIterator() : m_node() - { - } + LockFreeStackIterator() = default; LockFreeStackIterator(NodePtr node) : m_node(node) { @@ -79,7 +77,7 @@ public: } private: - NodePtr m_node; + NodePtr m_node{}; }; //------------------------------------------------------------------------------ diff --git a/include/xrpl/core/ClosureCounter.h b/include/xrpl/core/ClosureCounter.h index ef857ace72..bcdfa7d673 100644 --- a/include/xrpl/core/ClosureCounter.h +++ b/include/xrpl/core/ClosureCounter.h @@ -72,7 +72,7 @@ private: { private: ClosureCounter& counter_; - std::remove_reference_t closure_; + std::remove_reference_t closure_{}; static_assert( std::is_same_v()...)), Ret_t>, diff --git a/include/xrpl/ledger/detail/ReadViewFwdRange.h b/include/xrpl/ledger/detail/ReadViewFwdRange.h index bf40b04a6a..26ed22f11d 100644 --- a/include/xrpl/ledger/detail/ReadViewFwdRange.h +++ b/include/xrpl/ledger/detail/ReadViewFwdRange.h @@ -102,7 +102,7 @@ public: private: ReadView const* view_ = nullptr; - std::unique_ptr impl_; + std::unique_ptr impl_{}; std::optional mutable cache_; }; diff --git a/include/xrpl/protocol/KnownFormats.h b/include/xrpl/protocol/KnownFormats.h index fb93940fa8..73bc463abe 100644 --- a/include/xrpl/protocol/KnownFormats.h +++ b/include/xrpl/protocol/KnownFormats.h @@ -179,10 +179,10 @@ private: // One of the situations where a std::forward_list is useful. We want to // store each Item in a place where its address won't change. So a node- // based container is appropriate. But we don't need searchability. - std::forward_list formats_; + std::forward_list formats_{}; - boost::container::flat_map names_; - boost::container::flat_map types_; + boost::container::flat_map names_{}; + boost::container::flat_map types_{}; friend Derived; }; diff --git a/include/xrpl/protocol/STBitString.h b/include/xrpl/protocol/STBitString.h index 7bd270a98c..de038cce32 100644 --- a/include/xrpl/protocol/STBitString.h +++ b/include/xrpl/protocol/STBitString.h @@ -19,7 +19,7 @@ public: using value_type = base_uint; private: - value_type value_; + value_type value_{}; public: STBitString() = default; diff --git a/include/xrpl/rdb/DatabaseCon.h b/include/xrpl/rdb/DatabaseCon.h index 7400593214..579f30516b 100644 --- a/include/xrpl/rdb/DatabaseCon.h +++ b/include/xrpl/rdb/DatabaseCon.h @@ -94,7 +94,7 @@ public: struct CheckpointerSetup { - JobQueue* jobQueue; + JobQueue* jobQueue{}; std::reference_wrapper registry; }; diff --git a/include/xrpl/tx/SignerEntries.h b/include/xrpl/tx/SignerEntries.h index 0b997b3e4d..91fc4bd030 100644 --- a/include/xrpl/tx/SignerEntries.h +++ b/include/xrpl/tx/SignerEntries.h @@ -42,10 +42,10 @@ public: } // For sorting to look for duplicate accounts - friend bool - operator<(SignerEntry const& lhs, SignerEntry const& rhs) + friend auto + operator<=>(SignerEntry const& lhs, SignerEntry const& rhs) { - return lhs.account < rhs.account; + return lhs.account <=> rhs.account; } friend bool diff --git a/include/xrpl/tx/applySteps.h b/include/xrpl/tx/applySteps.h index ee7faeebd3..d42ca2c118 100644 --- a/include/xrpl/tx/applySteps.h +++ b/include/xrpl/tx/applySteps.h @@ -202,7 +202,7 @@ public: /// Success flag - whether the transaction is likely to /// claim a fee - bool const likelyToClaimFee; + bool const likelyToClaimFee{}; /// Constructor template diff --git a/src/libxrpl/ledger/PaymentSandbox.cpp b/src/libxrpl/ledger/PaymentSandbox.cpp index e517beaab5..6b38c4840c 100644 --- a/src/libxrpl/ledger/PaymentSandbox.cpp +++ b/src/libxrpl/ledger/PaymentSandbox.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include diff --git a/src/libxrpl/ledger/helpers/CredentialHelpers.cpp b/src/libxrpl/ledger/helpers/CredentialHelpers.cpp index 37f7db3677..18cb44b461 100644 --- a/src/libxrpl/ledger/helpers/CredentialHelpers.cpp +++ b/src/libxrpl/ledger/helpers/CredentialHelpers.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/src/libxrpl/tx/transactors/account/SignerListSet.cpp b/src/libxrpl/tx/transactors/account/SignerListSet.cpp index 7e236af21b..87eb69e706 100644 --- a/src/libxrpl/tx/transactors/account/SignerListSet.cpp +++ b/src/libxrpl/tx/transactors/account/SignerListSet.cpp @@ -257,11 +257,8 @@ SignerListSet::validateQuorumAndSignerEntries( } // Make sure there are no duplicate signers. - // SignerEntry only defines operator< and operator==, not the full - // std::totally_ordered set required by std::ranges::less, so the - // ranges version does not compile. NOLINTNEXTLINE(modernize-use-ranges) XRPL_ASSERT( - std::is_sorted(signers.begin(), signers.end()), + std::ranges::is_sorted(signers), "xrpl::SignerListSet::validateQuorumAndSignerEntries : sorted " "signers"); if (std::ranges::adjacent_find(signers) != signers.end()) diff --git a/src/libxrpl/tx/transactors/delegate/DelegateSet.cpp b/src/libxrpl/tx/transactors/delegate/DelegateSet.cpp index 5a73bb3561..9fd67f877d 100644 --- a/src/libxrpl/tx/transactors/delegate/DelegateSet.cpp +++ b/src/libxrpl/tx/transactors/delegate/DelegateSet.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include diff --git a/src/libxrpl/tx/transactors/nft/NFTokenMint.cpp b/src/libxrpl/tx/transactors/nft/NFTokenMint.cpp index b8150c3261..6043d918c2 100644 --- a/src/libxrpl/tx/transactors/nft/NFTokenMint.cpp +++ b/src/libxrpl/tx/transactors/nft/NFTokenMint.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index 758d16931c..1f4376a656 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -41,7 +41,6 @@ #include #include -#include #include #include #include diff --git a/src/xrpld/app/misc/TxQ.h b/src/xrpld/app/misc/TxQ.h index fa7e573071..621f3b8c60 100644 --- a/src/xrpld/app/misc/TxQ.h +++ b/src/xrpld/app/misc/TxQ.h @@ -415,7 +415,7 @@ private: // Number of transactions expected per ledger. // One more than this value will be accepted // before escalation kicks in. - std::size_t const txnsExpected; + std::size_t const txnsExpected{}; // Based on the median fee of the LCL. Used // when fee escalation kicks in. FeeLevel64 const escalationMultiplier; diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index c8b249cd74..a799ad4834 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include