From 0814a63232c6b6cad47681d81c67ac6a312a777b Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Tue, 6 May 2025 09:25:32 +0700 Subject: [PATCH] chore: fix warnings --- src/ripple/app/rdb/backend/RWDBDatabase.h | 3 ++- src/ripple/overlay/impl/Handshake.cpp | 9 +++++---- src/test/core/SociDB_test.cpp | 13 +++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/ripple/app/rdb/backend/RWDBDatabase.h b/src/ripple/app/rdb/backend/RWDBDatabase.h index 3981691bc..593e12348 100644 --- a/src/ripple/app/rdb/backend/RWDBDatabase.h +++ b/src/ripple/app/rdb/backend/RWDBDatabase.h @@ -224,7 +224,8 @@ public: if (!ledger->info().accountHash.isNonZero()) { - JLOG(j.fatal()) << "AH is zero: " << getJson({*ledger, {}}); + JLOG(j.fatal()) + << "AH is zero: " << getJson({*ledger, {}}).asString(); assert(false); } diff --git a/src/ripple/overlay/impl/Handshake.cpp b/src/ripple/overlay/impl/Handshake.cpp index 11b75e28d..5aa6ade58 100644 --- a/src/ripple/overlay/impl/Handshake.cpp +++ b/src/ripple/overlay/impl/Handshake.cpp @@ -239,8 +239,7 @@ verifyHandshake( throw std::runtime_error("Invalid server domain"); } - // Check the network. Omitting Network-ID (on either side ours, or theirs) - // means NID=0 + if (auto const iter = headers.find("Network-ID"); iter != headers.end()) { uint32_t peer_nid = 0; if (auto const iter = headers.find("Network-ID"); iter != headers.end()) @@ -250,8 +249,10 @@ verifyHandshake( throw std::runtime_error("Invalid peer network identifier"); } - uint32_t our_nid = networkID ? *networkID : 0; - if (peer_nid != our_nid) + if (!beast::lexicalCastChecked(peer_nid, std::string(iter->value()))) + throw std::runtime_error("Invalid peer network identifier"); + + if (networkID && peer_nid != *networkID) throw std::runtime_error("Peer is on a different network"); } diff --git a/src/test/core/SociDB_test.cpp b/src/test/core/SociDB_test.cpp index 875af9aa0..c0365ad9a 100644 --- a/src/test/core/SociDB_test.cpp +++ b/src/test/core/SociDB_test.cpp @@ -226,13 +226,15 @@ public: // SOCI requires boost::optional (not std::optional) as // parameters. boost::optional ig; - boost::optional uig; + // Known bug: https://github.com/SOCI/soci/issues/926 + // boost::optional uig; + uint32_t uig = 0; boost::optional big; boost::optional ubig; s << "SELECT I, UI, BI, UBI from STT;", soci::into(ig), soci::into(uig), soci::into(big), soci::into(ubig); BEAST_EXPECT( - *ig == id[0] && *uig == uid[0] && *big == bid[0] && + *ig == id[0] && uig == uid[0] && *big == bid[0] && *ubig == ubid[0]); } catch (std::exception&) @@ -357,18 +359,13 @@ public: bfs::remove(dbPath); } void - testSQLite() + run() override { testSQLiteFileNames(); testSQLiteSession(); testSQLiteSelect(); testSQLiteDeleteWithSubselect(); } - void - run() override - { - testSQLite(); - } }; BEAST_DEFINE_TESTSUITE(SociDB, core, ripple);