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<uint256> 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.
This commit is contained in:
Pratik Mankawde
2026-09-03 15:01:57 +01:00
parent a214db3a90
commit 10c165526f
2 changed files with 4 additions and 7 deletions

View File

@@ -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
}

View File

@@ -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;