Warnings in tests are errors#7951
Merged
achamayou merged 9 commits intoJun 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make warnings in CCF’s C++ unit tests fail the build (treat warnings as errors) by enabling stricter compiler warning flags for unit-test targets and then updating a broad set of tests (plus a few supporting headers) to eliminate common warning sources (unused variables, signed/unsigned mismatches, unsafe strerror, VLAs, etc).
Changes:
- Enable warning/error compile flags for unit test targets via CMake (
add_warning_checks). - Introduce and adopt a thread-safe
ccf::nonstd::strerror()wrapper to replace concurrency-unsafestd::strerror. - Refactor many tests to avoid warnings (unused variables, narrowing, shadowing, unused captures, designated init completeness, etc).
Custom instructions used:
.github/copilot-instructions.md.github/instructions/reviewing.instructions.md
Reviewed changes
Copilot reviewed 46 out of 46 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tls/test/main.cpp | Replace strerror, remove VLAs, tighten test buffer handling |
| src/tasks/test/fan_in_tasks.cpp | Fix signed/unsigned loop variable warnings |
| src/tasks/test/demo/clients.h | Fix signed/unsigned / implicit conversion warnings |
| src/tasks/test/basic_tasks.cpp | Remove unused WaitPoint variables |
| src/snapshots/snapshot_manager.h | Use thread-safe ccf::nonstd::strerror in error paths |
| src/pal/test/snp_attestation_validation.cpp | Fill designated initializers to silence warnings |
| src/node/test/snapshotter.cpp | Update aggregate init / naming to avoid warnings |
| src/node/test/snapshot.cpp | Rename to avoid shadowing/unused warnings |
| src/node/test/node_info_json.cpp | Expand initializer to match updated struct layout |
| src/node/test/network_identity_subsystem.cpp | Silence nodiscard/unused-result warnings in throw checks |
| src/node/test/historical_queries.cpp | Remove unused locals/lambdas; rename loop vars |
| src/node/test/encryptor.cpp | Assert commit result rather than unused variable |
| src/node/test/channels.cpp | Remove unused locals; adjust switches/loop vars |
| src/node/rpc/test/tx_status_test.cpp | Remove unused constants |
| src/node/rpc/test/node_frontend_test.cpp | Rename locals; adjust status expectations (test logic) |
| src/node/rpc/test/frontend_test.cpp | Remove unused lambda captures; rename locals |
| src/node/rpc/test/frontend_test_infra.h | Rename locals to avoid shadowing/unreferenced warnings |
| src/kv/test/kv_test.cpp | Remove unused locals; rename variables; fix switch completeness |
| src/kv/test/kv_snapshot.cpp | Remove unused locals; rename constants/handles; reduce unused vars |
| src/kv/test/kv_dynamic_tables.cpp | Remove unused handle variable |
| src/kv/test/kv_contention.cpp | Rename loop variables to avoid shadowing and warnings |
| src/indexing/test/lfs.cpp | Fix signed/unsigned loops; remove unused constant |
| src/indexing/test/indexing.cpp | Remove unused constants/aliases |
| src/host/test/ledger.cpp | Add [[maybe_unused]], fix loop index types, rename locals |
| src/host/tcp.h | Replace std::strerror with ccf::nonstd::strerror |
| src/host/ledger.h | Replace std::strerror with ccf::nonstd::strerror |
| src/endpoints/test/endpoint_registry.cpp | Rename locals to avoid unused/shadowing warnings |
| src/ds/test/work_beacon.cpp | Fix loop index types to avoid sign warnings |
| src/ds/test/serializer.cpp | Mark unused helper; rename locals to avoid shadowing |
| src/ds/test/ring_buffer.cpp | Fix loop types; remove unused captures; fix implicit conversions |
| src/ds/test/oversized.cpp | Rename variables to avoid shadowing/unused warnings |
| src/ds/test/nonstd.cpp | Rename locals to avoid shadowing/unused warnings |
| src/ds/test/messaging.cpp | Fix incorrect unconditional REQUIRE; remove unused lambda/vars |
| src/ds/test/map_test.cpp | Rename locals to avoid shadowing; fix index warnings |
| src/ds/test/json_schema.cpp | Avoid reference-to-temporary warnings / adjust loop var |
| src/ds/test/dl_list.cpp | Fully initialize aggregate to avoid missing-field warnings |
| src/ds/system.h | Replace strerror with ccf::nonstd::strerror |
| src/ds/files.h | Replace strerror with ccf::nonstd::strerror in file helpers |
| src/crypto/test/crypto.cpp | Rename locals, fix loop index types, avoid shadowing |
| src/consensus/aft/test/main.cpp | Remove redundant locals; fix loop/index conversions; simplify lambda captures |
| src/consensus/aft/test/logging_stub.h | Add virtual destructors; mark unused; avoid unused-result warnings |
| src/consensus/aft/test/committable_suffix.cpp | Fix implicit conversion warnings from rand() result |
| include/ccf/pal/snp_ioctl6.h | Replace strerror with nonstd::strerror |
| include/ccf/ds/nonstd.h | Add thread-safe strerror wrapper implementation |
| include/ccf/ds/contiguous_set.h | Fix narrowing/sign conversion warnings; remove unused local |
| cmake/common.cmake | Apply add_warning_checks() to unit-test targets |
achamayou
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These changes are pristine, unseen, unsullied by human eyes. They exist beyond a quality assessment. I wrote this as a joke and then scrolled down a little and realised this include diffs from a totally different PR! Oh well, I'll deal with that tomorrow.