Set bugprone-unused-return-value.AllowCastToVoid
What changed, and why it matters
This commit is a code-style and static-analysis configuration change. It tells the clang-tidy linter to allow discarding function return values when the call is explicitly cast to void, and updates a few places in benchmark, test, and HTTP server code to use that style instead of a temporary variable marked 'maybe unused'. There is no security-relevant behavior change.
No security action required. Treat as a normal lint/style maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds AllowCastToVoid: true to the bugprone-unused-return-value clang-tidy check and replaces [[maybe_unused]] auto _{…} with (void)… in four non-production locations: a coin-selection benchmark, the HTTP request enqueue path, an IPC test, and a wallet fuzz test. The runtime behavior is identical; only the suppression mechanism for the static analyzer changes. The commit message explicitly frames this as a cleanup that can be revisited with C++26’s _ placeholder.
Changed components
src/.clang-tidysrc/bench/coin_selection.cppsrc/httpserver.cppsrc/ipc/test/ipc_test.cppsrc/wallet/test/fuzz/spend.cppInspect captured patch +6 / −6
diff --git a/src/.clang-tidy b/src/.clang-tidy
index da53a588..0f69a0b0 100644
--- a/src/.clang-tidy
+++ b/src/.clang-tidy
@@ -39,3 +39,5 @@ CheckOptions:
value: false
- key: bugprone-unused-return-value.CheckedReturnTypes
value: '^::std::error_code$;^::std::error_condition$;^::std::errc$;^::std::expected$;^::util::Result$;^::util::Expected$'
+ - key: bugprone-unused-return-value.AllowCastToVoid
+ value: true # Can be removed with C++26 once the _ placeholder exists.
diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp
index 2150d800..04de5990 100644
--- a/src/bench/coin_selection.cpp
+++ b/src/bench/coin_selection.cpp
@@ -130,7 +130,7 @@ static void BnBExhaustion(benchmark::Bench& bench)
bench.run([&] {
// Benchmark
CAmount target = make_hard_case(17, utxo_pool);
- [[maybe_unused]] auto _{SelectCoinsBnB(utxo_pool, target, /*cost_of_change=*/0, MAX_STANDARD_TX_WEIGHT)}; // Should exhaust
+ (void)SelectCoinsBnB(utxo_pool, target, /*cost_of_change=*/0, MAX_STANDARD_TX_WEIGHT); // Should exhaust
// Cleanup
utxo_pool.clear();
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index abfcb455..aa648151 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -330,7 +330,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
std::unique_ptr<HTTPWorkItem> item(new HTTPWorkItem(std::move(hreq), path, i->handler));
assert(g_work_queue);
if (g_work_queue->Enqueue(item.get())) {
- [[maybe_unused]] auto _{item.release()}; /* if true, queue took ownership */
+ (void)item.release(); /* if true, queue took ownership */
} else {
LogWarning("Request rejected because http work queue depth exceeded, it can be increased with the -rpcworkqueue= setting");
item->req->WriteReply(HTTP_SERVICE_UNAVAILABLE, "Work queue depth exceeded");
diff --git a/src/ipc/test/ipc_test.cpp b/src/ipc/test/ipc_test.cpp
index 506facde..1acfb01c 100644
--- a/src/ipc/test/ipc_test.cpp
+++ b/src/ipc/test/ipc_test.cpp
@@ -63,9 +63,7 @@ void IpcPipeTest()
auto foo_client = std::make_unique<mp::ProxyClient<gen::FooInterface>>(
connection_client->m_rpc_system->bootstrap(mp::ServerVatId().vat_id).castAs<gen::FooInterface>(),
connection_client.get(), /* destroy_connection= */ true);
- {
- [[maybe_unused]] auto _{connection_client.release()};
- }
+ (void)connection_client.release();
foo_promise.set_value(std::move(foo_client));
auto connection_server = std::make_unique<mp::Connection>(loop, kj::mv(pipe.ends[1]), [&](mp::Connection& connection) {
diff --git a/src/wallet/test/fuzz/spend.cpp b/src/wallet/test/fuzz/spend.cpp
index 99bc5345..552364a6 100644
--- a/src/wallet/test/fuzz/spend.cpp
+++ b/src/wallet/test/fuzz/spend.cpp
@@ -98,7 +98,7 @@ FUZZ_TARGET(wallet_create_transaction, .init = initialize_setup)
std::optional<unsigned int> change_pos;
if (fuzzed_data_provider.ConsumeBool()) change_pos = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
- [[maybe_unused]] auto _{CreateTransaction(*fuzzed_wallet.wallet, recipients, change_pos, coin_control)};
+ (void)CreateTransaction(*fuzzed_wallet.wallet, recipients, change_pos, coin_control);
}
} // namespace
} // namespace wallet
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.