From 10c165526f1fbd760c0cc4df031a7730158dc8f7 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Thu, 3 Sep 2026 15:01:57 +0100 Subject: [PATCH] refactor(telemetry): replace unused-parameter casts with maybe_unused Mirror::store() and Mirror::changedTo() silenced an unused parameter with a (void) cast in their telemetry-disabled arm. The warning was real: Mirror is instantiated in InboundTransactions.cpp. store()'s #else arm held nothing else, so it collapses to a bare #endif; changedTo() keeps its #else for the return. readProcFile() and measuredTrim() are added by this PR and gain [[nodiscard]]. MallocTrim.cpp predates the telemetry work, but neither function exists on develop, so this annotates declarations this branch authored rather than surrounding code. No caller discards either. --- include/xrpl/telemetry/Recording.h | 7 ++----- src/libxrpl/basics/MallocTrim.cpp | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/include/xrpl/telemetry/Recording.h b/include/xrpl/telemetry/Recording.h index 105890126a..9c8f8bfac1 100644 --- a/include/xrpl/telemetry/Recording.h +++ b/include/xrpl/telemetry/Recording.h @@ -252,12 +252,10 @@ public: * @param value The value to remember. */ void - store(T const& value) noexcept + store([[maybe_unused]] T const& value) noexcept { #ifdef XRPL_ENABLE_TELEMETRY value_ = value; -#else - (void)value; #endif } @@ -270,14 +268,13 @@ public: * False when compiled out, so a caller's reporting branch never runs. */ [[nodiscard]] bool - changedTo(T const& value) noexcept + changedTo([[maybe_unused]] T const& value) noexcept { #ifdef XRPL_ENABLE_TELEMETRY bool const changed = value_ != value; value_ = value; return changed; #else - (void)value; return false; #endif } diff --git a/src/libxrpl/basics/MallocTrim.cpp b/src/libxrpl/basics/MallocTrim.cpp index 885d857984..73d18f11e7 100644 --- a/src/libxrpl/basics/MallocTrim.cpp +++ b/src/libxrpl/basics/MallocTrim.cpp @@ -77,7 +77,7 @@ parseStatmRSSkB(std::string const& statm) * @param path Absolute path of the pseudo-file. * @return The file contents, or an empty string if it could not be opened. */ -std::string +[[nodiscard]] std::string readProcFile(std::string const& path) { std::ifstream ifs(path, std::ios::in | std::ios::binary); @@ -103,7 +103,7 @@ readProcFile(std::string const& path) * @return A fully populated report. Fields whose source syscall failed keep * their -1 "not measured" sentinel. */ -MallocTrimReport +[[nodiscard]] MallocTrimReport measuredTrim(std::size_t padBytes) { MallocTrimReport report;