#36167 [RFC] Enable `-Wunused`
| Reviewability | Reviews | Agreement | Size | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| #36167 [RFC] Enable `-Wunused` | CI failing | 0 | Mild | 548 + 59 tests | ||||||
|
|
|
|
| ||||||
Reviewability: ReadyStalePaused Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs. Size: lines added or modified outside tests, then in tests; greener = smaller. | ||||||||||
Goal
Enables `-Wunused` and related compiler warning flags in CMake, resolving existing unused variable and parameter warnings across the repository. It drops or comments out unused parameter names, adds `[[maybe_unused]]` attributes, refactors several RPC method implementations to use the `Arg<>()` helper, and includes temporary changes for vendored subtree dependencies.
Problem: The build system does not enable `-Wunused`, allowing unused code, variables, and parameters to silently accumulate across the codebase. This omission can conceal subtle programming errors where code or parameters were accidentally forgotten rather than intentionally omitted.
Evidence of importance:
- The PR description points to a recent case (#36137) of 'what was thought to be dead code, but it'd actually just been forgotten to be used'.
- The author links eight dead code removal PRs merged within the preceding two months (#35679, #35910, #35914, #35971, #36009, #36012, #36103, #36127) as evidence of churn that compiler warnings would prevent.
Scope: Contains three `[[nomerge]]` commits with fixes intended for external subtrees (minisketch, leveldb, and libmultiprocess). It also bundles an RPC argument lookup change in `GetParamIndex` alongside mechanical parameter silencing across 160 files.
Risk of a mistake: medium (build, rpc_api). RPC parameter parsing refactors and argument index adjustments could subtly alter RPC command behavior or error handling.
Changed since the previous assessment: Rebased to reflect several intervening PR merges (including #36275 and #36509), reducing the file touch count from 171 to 160.
Reviewability
Ready · CI failing
CI is red; check whether the failure is the PR's before a deep review.
Waiting on (from the thread read):
- reviewer: maflcko to review after author moved requested flags into #36509 2026-10-13
Agreement
Mild
objection that needs a change was answered, no reply from the objector (maflcko: Removing parameters like `self` causes unnecessary churn because they should be used more rather than removed, requiring)
Thread notes: Added maflcko's suggestion in rc:4255489957 to split out further flags, answered by fanquake creating #36509.
Objections, suggestions, and questions:
| Reviewer | Type | Harm, request, or question | Status | Must be | Author replied | Quote |
|---|---|---|---|---|---|---|
| maflcko (member) | suggestion, scope | Split finer-grained unused flags into a separate PR from unused parameter warnings | answered · author split a portion out into #36275 | answered | yes | 2026-09-16: 'Maybe be split up into a separate pull from the unused parameter warnings' Status from: 2026-09-16: fanquake: 'Split a portion out into #36275.' |
| maflcko (member) | objection, maintenance | Removing parameters like `self` causes unnecessary churn because they should be used more rather than removed, requiring touching the line again | answered · author asked for PRs using self and offered to split more out; maflcko linked #36384 | changed | yes | 2026-09-29: 'I think we want to use `self` here more, not remove it. But using it would require touching this line again.' Status from: 2026-09-29: fanquake: 'Are there any PRs currently doing this? I'll split more of this out.' |
| maflcko (member) | suggestion, scope | Split this warning flag and possibly `-Wunused-macros` out into a separate PR | answered · author put them into #36509 | answered | yes | 2026-10-13: 'can you split this one out? Possibly also -Wunused-macros (if meaningful, etc)?' Status from: 2026-10-13: fanquake: 'Put them into #36509.' |
Participants:
- maflcko (member, objection, 4 statements 2026-09-16 to 2026-10-13): objected to churn from removing parameters like `self` that should be used instead, and suggested splitting warning flags
Files
118 lines under test/bench/ci.
- src/rpc/blockchain.cpp +36/-52
- src/rpc/mempool.cpp +14/-24
- src/rpc/rawtransaction.cpp +16/-22
- src/wallet/scriptpubkeyman.h +18/-18
- src/wallet/rpc/transactions.cpp +14/-21
- src/rpc/net.cpp +15/-18
- src/wallet/walletdb.cpp +16/-16
- src/memusage.h +15/-15
- src/wallet/rpc/wallet.cpp +15/-15
- src/ipc/libmultiprocess/include/mp/type-struct.h +14/-14
- src/wallet/rpc/addresses.cpp +14/-14
- src/wallet/rpc/spend.cpp +12/-15
- src/wallet/rpc/coins.cpp +8/-18
- src/ipc/libmultiprocess/include/mp/type-number.h +12/-12
- src/kernel/bitcoinkernel_wrapper.h +12/-12
- src/script/descriptor.cpp +12/-12
- src/script/signingprovider.h +12/-12
- src/script/sign.cpp +10/-10
- src/rpc/mining.cpp +9/-9
- src/rpc/util.cpp +9/-9
- src/validationinterface.h +9/-9
- src/addresstype.cpp +8/-8
- src/kernel/notifications_interface.h +7/-7
- src/rpc/node.cpp +7/-7
- src/wallet/test/walletload_tests.cpp +7/-7
- src/ipc/capnp/common-types.h +6/-6
- src/ipc/libmultiprocess/test/mp/test/foo-types.h +6/-6
- src/test/util/net.cpp +6/-6
- src/wallet/rpc/backup.cpp +6/-6
- src/interfaces/chain.h +5/-5
- src/ipc/libmultiprocess/include/mp/proxy-types.h +5/-5
- src/ipc/libmultiprocess/include/mp/type-interface.h +5/-5
- src/leveldb/helpers/memenv/memenv.cc +5/-5
- src/sync.h +5/-5
- src/wallet/scriptpubkeyman.cpp +5/-5
- CMakeLists.txt +1/-7
- src/bitcoin-cli.cpp +4/-4
- src/index/base.h +4/-4
- src/qt/rpcconsole.cpp +4/-4
- src/rpc/server.cpp +4/-4
- src/script/interpreter.h +4/-4
- src/serialize.h +4/-4
- src/test/fuzz/signature_checker.cpp +4/-4
- src/test/kernel/test_kernel.cpp +4/-4
- src/test/pcp_tests.cpp +4/-4
- src/test/validation_chainstatemanager_tests.cpp +4/-4
- src/wallet/rpc/encrypt.cpp +4/-4
- src/wallet/wallet.cpp +4/-4
- src/bitcoin-chainstate.cpp +3/-3
- src/ipc/libmultiprocess/include/mp/type-message.h +3/-3
- src/leveldb/db/version_set.cc +3/-3
- src/net_processing.cpp +3/-3
- src/node/interfaces.cpp +3/-3
- src/qt/bitcoingui.cpp +3/-3
- src/qt/recentrequeststablemodel.cpp +6/-0
- src/test/fuzz/util/net.cpp +3/-3
- src/wallet/migrate.h +3/-3
- src/wallet/transaction.h +3/-3
- src/minisketch/src/fields/clmul_1byte.cpp +3/-2
- src/minisketch/src/fields/clmul_2bytes.cpp +3/-2
- src/minisketch/src/fields/clmul_3bytes.cpp +3/-2
- src/minisketch/src/fields/clmul_4bytes.cpp +3/-2
- src/minisketch/src/fields/clmul_5bytes.cpp +3/-2
- src/minisketch/src/fields/clmul_6bytes.cpp +3/-2
- src/minisketch/src/fields/clmul_7bytes.cpp +3/-2
- src/minisketch/src/fields/clmul_8bytes.cpp +3/-2
- src/rpc/fees.cpp +1/-4
- src/deploymentstatus.h +2/-2
- src/dummywallet.cpp +2/-2
- src/init.cpp +2/-2
- src/ipc/libmultiprocess/include/mp/type-chrono.h +2/-2
- src/ipc/libmultiprocess/include/mp/type-data.h +2/-2
- src/ipc/libmultiprocess/include/mp/type-string.h +2/-2
- src/ipc/libmultiprocess/include/mp/type-threadmap.h +2/-2
- src/kernel/coinstats.cpp +2/-2
- src/key_io.cpp +2/-2
- src/leveldb/table/table.cc +2/-2
- src/noui.cpp +2/-2
- src/qt/receivecoinsdialog.cpp +2/-2
- src/qt/sendcoinsdialog.cpp +2/-2
- src/random.cpp +2/-2
- src/rpc/output_script.cpp +2/-2
- src/rpc/signmessage.cpp +2/-2
- src/rpc/txoutproof.cpp +2/-2
- src/test/allocator_tests.cpp +2/-2
- src/test/fuzz/package_eval.cpp +2/-2
- src/test/httpserver_tests.cpp +2/-2
- src/test/rpc_tests.cpp +2/-2
- src/test/validation_block_tests.cpp +2/-2
- src/txgraph.cpp +2/-2
- src/zmq/zmqabstractnotifier.cpp +2/-2
- src/minisketch/src/fields/generic_1byte.cpp +2/-1
- src/minisketch/src/fields/generic_2bytes.cpp +2/-1
- src/minisketch/src/fields/generic_3bytes.cpp +2/-1
- src/minisketch/src/fields/generic_4bytes.cpp +2/-1
- src/minisketch/src/fields/generic_5bytes.cpp +2/-1
- src/minisketch/src/fields/generic_6bytes.cpp +2/-1
- src/minisketch/src/fields/generic_7bytes.cpp +2/-1
- src/minisketch/src/fields/generic_8bytes.cpp +2/-1
- src/cluster_linearize.h +1/-1
- src/core_memusage.h +1/-1
- src/crypto/ripemd160.cpp +1/-1
- src/crypto/sha1.cpp +1/-1
- src/crypto/sha256.cpp +1/-1
- src/init/bitcoin-qt.cpp +1/-1
- src/init/bitcoin-wallet.cpp +1/-1
- src/init/bitcoind.cpp +1/-1
- src/interfaces/init.h +1/-1
- src/interfaces/node.h +1/-1
- src/ipc/libmultiprocess/include/mp/type-context.h +1/-1
- src/ipc/libmultiprocess/include/mp/type-vector.h +1/-1
- src/kernel/bitcoinkernel.cpp +1/-1
- src/leveldb/db/db_impl.cc +1/-1
- src/leveldb/db/table_cache.cc +1/-1
- src/leveldb/table/iterator.cc +1/-1
- src/leveldb/util/env.cc +1/-1
- src/leveldb/util/env_posix.cc +1/-1
- src/leveldb/util/env_windows.cc +1/-1
- src/minisketch/src/int_utils.h +1/-1
- src/netbase.cpp +1/-1
- src/node/eviction.cpp +1/-1
- src/qt/addresstablemodel.cpp +1/-1
- src/qt/bitcoinamountfield.cpp +1/-1
- src/qt/guiutil.cpp +1/-1
- src/qt/notificator.cpp +1/-1
- src/qt/optionsdialog.cpp +1/-1
- src/qt/optionsmodel.cpp +1/-1
- src/qt/overviewpage.cpp +1/-1
- src/qt/psbtoperationsdialog.cpp +1/-1
- src/qt/qvaluecombobox.cpp +1/-1
- src/qt/splashscreen.cpp +1/-1
- src/qt/test/rpcnestedtests.cpp +1/-1
- src/qt/transactionrecord.cpp +1/-1
- src/rpc/external_signer.cpp +1/-1
- src/test/blockfilter_index_tests.cpp +1/-1
- src/test/checkqueue_tests.cpp +1/-1
- src/test/fuzz/crypto_diff_fuzz_chacha20.cpp +1/-1
- src/test/fuzz/miniscript.cpp +1/-1
- src/test/fuzz/partially_downloaded_block.cpp +1/-1
- src/test/fuzz/tx_pool.cpp +1/-1
- src/test/fuzz/util.cpp +1/-1
- src/test/miniscript_tests.cpp +1/-1
- src/test/net_tests.cpp +1/-1
- src/test/span_tests.cpp +1/-1
- src/test/util/chainstate.h +1/-1
- src/test/util/setup_common.cpp +1/-1
- src/test/validationinterface_tests.cpp +1/-1
- src/torcontrol.cpp +1/-1
- src/univalue/test/object.cpp +1/-1
- src/univalue/test/unitester.cpp +1/-1
- src/util/fs_helpers.cpp +1/-1
- src/wallet/db.h +1/-1
- src/wallet/migrate.cpp +1/-1
- src/wallet/rpc/signmessage.cpp +1/-1
- src/wallet/sqlite.cpp +1/-1
- src/wallet/test/fuzz/fees.cpp +1/-1
- src/wallet/test/util.h +1/-1
- src/wallet/test/wallet_tests.cpp +1/-1
- src/zmq/zmqnotificationinterface.cpp +1/-1
- src/zmq/zmqrpc.cpp +1/-1
Card
The short text the ranking pass compares across PRs.
Enables `-Wunused` compiler flags in CMake and silences existing warnings across 160 files by omitting unused parameter names, adding `[[maybe_unused]]`, and refactoring RPC argument helpers. Without warning enforcement, dead code accumulates and can mask logic bugs where intended variable or parameter usage was forgotten (as observed in #36137). Merging is blocked on upstream subtree PRs in Minisketch and libmultiprocess.
Data
thread read through 2026-10-13 (7 statements), head 5ac997cfb4
labels: CI failed · draft
Categories
Build and CI
P3 · cleanup (ranking pass: Moved up from 35: cited as catching a real bug class (#36137), unlike the purely cosmetic warning flags below)
Enabling `-Wunused` prevents silent accumulation of dead code and helps avoid bugs where parameters are accidentally forgotten. The author cites a recent case where forgotten code was mistaken for dead code (#36137) and eight dead-code PRs merged within two months, showing real hygiene value that is nonetheless reasonably deferrable.
Membership: Modifies CMakeLists.txt to enable `-Wunused` compiler warning flags across the build.
Factors: security/stability 1, bug 0, performance 0, user value 0, leverage 1
RPC / REST / ZMQ
P4 · cleanup
Internal refactoring of RPC parameter lookup has no user-visible interface effect. It represents minor code modernization bundled alongside the warning fixes.
Membership: Modifies RPC handling in GetParamIndex and refactors multiple RPC method implementations to use the Arg<>() helper.
Factors: security/stability 1, bug 0, performance 0, user value 0, leverage 1