From 7b581443d1bdc8943e0baebe04c3f1fb48f489a5 Mon Sep 17 00:00:00 2001 From: tequ Date: Tue, 29 Apr 2025 07:25:55 +0900 Subject: [PATCH] Suppress build warning introduced in Catalogue (#499) --- src/ripple/app/ledger/Ledger.cpp | 2 +- src/ripple/rpc/handlers/Catalogue.cpp | 6 ++--- src/ripple/shamap/impl/SHAMap.cpp | 12 ++++------ src/test/rpc/Catalogue_test.cpp | 32 ++++++++++++++------------- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 345c3bb28..b013b35a0 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -311,10 +311,10 @@ Ledger::Ledger( Family& family, SHAMap const& baseState) : mImmutable(false) - , info_(info) , txMap_(SHAMapType::TRANSACTION, family) , stateMap_(baseState, true) , rules_{config.features} + , info_(info) , j_(beast::Journal(beast::Journal::getNullSink())) { } diff --git a/src/ripple/rpc/handlers/Catalogue.cpp b/src/ripple/rpc/handlers/Catalogue.cpp index de025de1a..8ca4425d6 100644 --- a/src/ripple/rpc/handlers/Catalogue.cpp +++ b/src/ripple/rpc/handlers/Catalogue.cpp @@ -69,7 +69,7 @@ static constexpr uint16_t CATALOGUE_VERSION_MASK = 0x00FF; // Lower 8 bits for version static constexpr uint16_t CATALOGUE_COMPRESS_LEVEL_MASK = 0x0F00; // Bits 8-11: compression level -static constexpr uint16_t CATALOGUE_RESERVED_MASK = +[[maybe_unused]] static constexpr uint16_t CATALOGUE_RESERVED_MASK = 0xF000; // Bits 12-15: reserved std::string @@ -229,7 +229,7 @@ class CatalogueSizePredictor private: uint32_t minLedger_; uint32_t maxLedger_; - uint64_t headerSize_; + [[maybe_unused]] uint64_t headerSize_; // Keep track of actual bytes uint64_t totalBytesWritten_; @@ -246,9 +246,9 @@ public: : minLedger_(minLedger) , maxLedger_(maxLedger) , headerSize_(headerSize) - , processedLedgers_(0) , totalBytesWritten_(headerSize) , firstLedgerSize_(0) + , processedLedgers_(0) { } diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index 972cc64fb..46c61bbc4 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -1301,10 +1301,8 @@ SHAMap::serializeToStream( std::size_t nodeCount = 0; - auto serializeLeaf = [&stream, - &localBytesWritten, - flushThreshold, - &tryFlush](SHAMapLeafNode const& node) -> bool { + auto serializeLeaf = [&stream, &localBytesWritten, &tryFlush]( + SHAMapLeafNode const& node) -> bool { // write the node type auto t = node.getType(); stream.write(reinterpret_cast(&t), 1); @@ -1335,10 +1333,8 @@ SHAMap::serializeToStream( return !stream.fail(); }; - auto serializeRemovedLeaf = [&stream, - &localBytesWritten, - flushThreshold, - &tryFlush](uint256 const& key) -> bool { + auto serializeRemovedLeaf = + [&stream, &localBytesWritten, &tryFlush](uint256 const& key) -> bool { // to indicate a node is removed it is written with a removal type auto t = SHAMapNodeType::tnREMOVE; stream.write(reinterpret_cast(&t), 1); diff --git a/src/test/rpc/Catalogue_test.cpp b/src/test/rpc/Catalogue_test.cpp index 981e05940..9cafebd07 100644 --- a/src/test/rpc/Catalogue_test.cpp +++ b/src/test/rpc/Catalogue_test.cpp @@ -401,18 +401,8 @@ class Catalogue_test : public beast::unit_test::suite sourceLedger->info().accepted == loadedLedger->info().accepted); // Check SLE counts - std::size_t sourceCount = 0; - std::size_t loadedCount = 0; - - for (auto const& sle : sourceLedger->sles) - { - sourceCount++; - } - - for (auto const& sle : loadedLedger->sles) - { - loadedCount++; - } + std::size_t sourceCount = std::ranges::distance(sourceLedger->sles); + std::size_t loadedCount = std::ranges::distance(loadedLedger->sles); BEAST_EXPECT(sourceCount == loadedCount); @@ -561,7 +551,13 @@ class Catalogue_test : public beast::unit_test::suite using namespace test::jtx; // Create environment and test data - Env env{*this, envconfig(), features}; + Env env{ + *this, + envconfig(), + features, + nullptr, + beast::severities::kDisabled, + }; prepareLedgerData(env, 3); boost::filesystem::path tempDir = @@ -652,7 +648,13 @@ class Catalogue_test : public beast::unit_test::suite using namespace test::jtx; // Create environment and test data - Env env{*this, envconfig(), features}; + Env env{ + *this, + envconfig(), + features, + nullptr, + beast::severities::kDisabled, + }; prepareLedgerData(env, 3); boost::filesystem::path tempDir = @@ -829,7 +831,7 @@ class Catalogue_test : public beast::unit_test::suite { auto result = env.client().invoke( "catalogue_status", Json::objectValue)[jss::result]; - std::cout << to_string(result) << "\n"; + // std::cout << to_string(result) << "\n"; BEAST_EXPECT(result[jss::job_status] == "no_job_running"); }