bench: Require semicolon after BENCHMARK(foo)
What changed, and why it matters
This is a minor code cleanup in Bitcoin Core's internal benchmarking test code. It changes how a macro is written so callers must add a semicolon, and it updates a type alias style. It does not affect the live Bitcoin network, wallets, or consensus rules.
No security action needed; this is a normal refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies the BENCHMARK macro in src/bench/bench.h so that its expansion no longer includes a trailing semicolon; callers now supply it explicitly. It also changes ‘typedef std::function
Changed components
src/bench/bench.hsrc/bench/prevector.cppsrc/bench/wallet_create_tx.cppInspect captured patch +6 / −6
diff --git a/src/bench/bench.h b/src/bench/bench.h
index 14f0c4b0..f7df42a3 100644
--- a/src/bench/bench.h
+++ b/src/bench/bench.h
@@ -38,7 +38,7 @@ namespace benchmark {
using ankerl::nanobench::Bench;
-typedef std::function<void(Bench&)> BenchFunction;
+using BenchFunction = std::function<void(Bench&)>;
struct Args {
bool is_list_only;
@@ -64,8 +64,8 @@ public:
};
} // namespace benchmark
-// BENCHMARK(foo) expands to: benchmark::BenchRunner bench_runner_foo{"foo", foo};
+// BENCHMARK(foo); expands to: benchmark::BenchRunner bench_runner_foo{"foo", foo};
#define BENCHMARK(n) \
- benchmark::BenchRunner PASTE2(bench_runner_, n){STRINGIZE(n), n};
+ benchmark::BenchRunner PASTE2(bench_runner_, n) { STRINGIZE(n), n }
#endif // BITCOIN_BENCH_BENCH_H
diff --git a/src/bench/prevector.cpp b/src/bench/prevector.cpp
index e3e7ae87..8d386ec2 100644
--- a/src/bench/prevector.cpp
+++ b/src/bench/prevector.cpp
@@ -116,7 +116,7 @@ static void PrevectorFillVectorIndirect(benchmark::Bench& bench)
{ \
Prevector##name<nontrivial_t>(bench); \
} \
- BENCHMARK(Prevector##name##Nontrivial); \
+ BENCHMARK(Prevector##name##Nontrivial); \
static void Prevector##name##Trivial(benchmark::Bench& bench) \
{ \
Prevector##name<trivial_t>(bench); \
diff --git a/src/bench/wallet_create_tx.cpp b/src/bench/wallet_create_tx.cpp
index 5a6df178..8ff1e39a 100644
--- a/src/bench/wallet_create_tx.cpp
+++ b/src/bench/wallet_create_tx.cpp
@@ -215,6 +215,6 @@ static void WalletCreateTxUsePresetInputsAndCoinSelection(benchmark::Bench& benc
static void WalletAvailableCoins(benchmark::Bench& bench) { AvailableCoins(bench, {OutputType::BECH32M}); }
-BENCHMARK(WalletCreateTxUseOnlyPresetInputs)
-BENCHMARK(WalletCreateTxUsePresetInputsAndCoinSelection)
+BENCHMARK(WalletCreateTxUseOnlyPresetInputs);
+BENCHMARK(WalletCreateTxUsePresetInputsAndCoinSelection);
BENCHMARK(WalletAvailableCoins);
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.