Merged
Conversation
achamayou
reviewed
Mar 4, 2026
achamayou
reviewed
Mar 4, 2026
achamayou
reviewed
Mar 4, 2026
achamayou
reviewed
Mar 4, 2026
achamayou
reviewed
Mar 4, 2026
achamayou
reviewed
Mar 4, 2026
achamayou
reviewed
Mar 4, 2026
eddyashton
reviewed
Mar 6, 2026
Co-authored-by: Amaury Chamayou <amaury@xargs.fr>
achamayou
reviewed
Mar 16, 2026
achamayou
reviewed
Mar 16, 2026
achamayou
approved these changes
Mar 16, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens compiler warnings by enabling -Wswitch-enum and updates many switch statements across the codebase to explicitly cover enum values (often replacing broad default branches with specific cases), alongside some adjustments to error handling when unexpected enum values are encountered.
Changes:
- Enable
-Wswitch-enumin the CMake warning checks. - Update numerous enum
switchstatements to explicitly enumerate cases and make “unknown”/invalid states more explicit (often viathrow). - Minor related cleanups (eg removing unreachable returns, refining log/error messages).
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cmake/preproject.cmake | Enables -Wswitch-enum under warning checks. |
| src/http/curl.h | Suppresses -Wswitch-enum for a deliberately non-exhaustive llhttp-method switch (currently Clang-only). |
| src/node/channels.h | Adjusts unestablished-channel handling to explicitly case on NodeMsgType::channel_msg. |
| src/consensus/aft/raft.h | Refines switch handling/logging for a specific Raft message type. |
| src/js/permissions_checks.h | Makes TxAccess handling explicit (replacing a default with a named case). |
| src/ds/actors.h | Makes ActorsType::unknown explicit (replacing default). |
| src/node/node_state.h | Refines node inbound message-type switch handling and error reporting. |
| src/node/hooks.h | Throws on unknown NodeStatus in configuration change hook. |
| src/node/rpc/node_frontend_utils.h | Makes “Verified”/unknown quote verification results explicit via exceptions. |
| src/node/rpc/node_frontend.h | Makes QuoteFormat handling explicit in service creation path. |
| src/node/quote.cpp | Makes QuoteFormat handling explicit in host data extraction. |
| src/pal/quote_generation.h | Makes platform cases explicit and returns early from handled cases. |
| src/node/uvm_endorsements.cpp | Makes unsupported JWK key type explicit (OKP). |
| src/kv/generic_serialise_wrapper.h | Includes serialized helpers and throws on invalid security domain sentinel. |
| src/enclave/tls_session.h | Makes TLS session status handling more explicit; adds an exception on unknown status in one switch. |
| src/quic/quic_session.h | Makes QUIC session status switches more explicit. |
| src/host/tcp.h | Enumerates Status cases more explicitly and tightens unexpected-state handling. |
| src/host/udp.h | Makes FRESH state explicit in switch. |
| src/crypto/openssl/hash.h | Removes unreachable return nullptr. |
| include/ccf/service/tables/proposals.h | Adds formatter support for ProposalState::FAILED; throws on unknown state. |
| include/ccf/endpoint.h | Refines formatter implementation and error message for invalid ForwardingRequired. |
| include/ccf/pal/attestation_sev_snp.h | Improves error message with unsupported product value. |
| include/ccf/crypto/jwk.h | Tightens curve mapping with explicit invalid/unsupported cases. |
| include/ccf/crypto/curve.h | Tightens ECDSA curve mapping and error message text. |
| samples/apps/programmability/programmability.cpp | Makes ApiResult handling explicit for additional cases. |
| src/node/recovery_decision_protocol.cpp | Adds explicit handling for OPEN state in a state machine switch. |
Comments suppressed due to low confidence (2)
src/js/permissions_checks.h:86
- After replacing
defaultwith an explicitTxAccess::GOV_ROcase, this switch no longer handles unexpectedexecution_contextvalues, and there is no return after the switch. If an invalid enum value is ever observed (eg via cast/deserialisation), this becomes undefined behaviour (control reaches end without returning). Add adefault(eg return ILLEGAL/throw) or an explicit unreachable after the switch.
switch (execution_context)
{
case (TxAccess::APP_RW):
{
return KVAccessPermissions::READ_WRITE;
}
case (TxAccess::APP_RO):
{
return KVAccessPermissions::READ_ONLY;
}
case (TxAccess::GOV_RW):
{
return KVAccessPermissions::WRITE_ONLY;
}
case (TxAccess::GOV_RO):
{
return KVAccessPermissions::ILLEGAL;
}
}
src/ds/actors.h:45
- This switch no longer has a
default, and the function has no return after the switch. IfActorsTypeever holds an invalid value (eg via cast/deserialisation), control can reach the end without returning (UB). Add adefaultreturn or an explicit unreachable/throw after the switch to make this total.
{
return "node";
}
case ActorsType::unknown:
{
return "";
}
}
}
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
achamayou
approved these changes
Mar 17, 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.
This adds
-Wswitch-enumwhich requires a branch for every type of an enum.And it also adds
-Wcovered-switch-defaultwhich throws an error if every case of an enum is covered.And then fixes all of the switch statements.