Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1de94e0
First batch of switch-exhaustiveness
cjen1-msft Mar 3, 2026
02ea02f
spicier updates
cjen1-msft Mar 3, 2026
a112907
Make build happy
cjen1-msft Mar 3, 2026
42c6c6e
Merge branch 'main' into tired-switching
cjen1-msft Mar 4, 2026
5ffea65
fmt and minimise diff
cjen1-msft Mar 6, 2026
5932aa8
remove todo
cjen1-msft Mar 6, 2026
cd5585a
Apply suggestions from code review
cjen1-msft Mar 10, 2026
135303d
Switch-default rather than covered-switch-default
cjen1-msft Mar 16, 2026
831cdab
inline re_derive_sealing_key
cjen1-msft Mar 16, 2026
0546354
Clean up diff
cjen1-msft Mar 16, 2026
7a01d9f
Clean up diff
cjen1-msft Mar 16, 2026
cc05ec5
Minimise diff
cjen1-msft Mar 16, 2026
0fc5622
Comments from code review
cjen1-msft Mar 16, 2026
b994a7c
fmt
cjen1-msft Mar 16, 2026
9986d04
Fixup
cjen1-msft Mar 16, 2026
f528797
Merge remote-tracking branch 'upstream/main' into tired-switching
cjen1-msft Mar 16, 2026
7c5509c
Ensure no loop introduced in endpoint formatter
cjen1-msft Mar 16, 2026
2a9092d
cast to uint8_t rather than int
cjen1-msft Mar 16, 2026
6589180
Also for proposalState
cjen1-msft Mar 16, 2026
914ff75
fmt
cjen1-msft Mar 16, 2026
1615e05
Merge branch 'main' into tired-switching
cjen1-msft Mar 17, 2026
dc20a2a
Potential fix for pull request finding
cjen1-msft Mar 17, 2026
9cd7ee4
Use static-cast to int to get rid of clang error diagnostic disable
cjen1-msft Mar 17, 2026
8d1cc84
Copilot comment applied
cjen1-msft Mar 17, 2026
0014b34
Merge branch 'main' into tired-switching
cjen1-msft Mar 17, 2026
3122743
Merge branch 'main' into tired-switching
achamayou Mar 17, 2026
fee45b5
Merge branch 'main' into tired-switching
achamayou Mar 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/preproject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function(add_warning_checks name)
-Wno-unused-parameter
-Wno-unused-function
-Wshadow
-Wswitch-enum
)
endfunction()

Expand Down
8 changes: 7 additions & 1 deletion include/ccf/crypto/curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ namespace ccf::crypto
{
switch (ec)
{
case CurveID::NONE:
case CurveID::CURVE25519:
case CurveID::X25519:
{
throw std::logic_error(fmt::format("Invalid ECDSA curve: {}", ec));
}
case CurveID::SECP384R1:
return MDType::SHA384;
case CurveID::SECP256R1:
return MDType::SHA256;
default:
{
throw std::logic_error(fmt::format("Unhandled CurveID: {}", ec));
throw std::logic_error(fmt::format("Unhandled CurveId: {}", ec));
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions include/ccf/crypto/jwk.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ namespace ccf::crypto
{
switch (curve_id)
{
case CurveID::NONE:
case CurveID::CURVE25519:
case CurveID::X25519:
throw std::logic_error(
fmt::format("Invalid JWK EC CurveId {}", curve_id));
case CurveID::SECP384R1:
return JsonWebKeyECCurve::P384;
case CurveID::SECP256R1:
Expand All @@ -82,6 +87,9 @@ namespace ccf::crypto
{
switch (jwk_curve)
{
case JsonWebKeyECCurve::P521:
throw std::logic_error(
fmt::format("Unsupported JWK curve {}", jwk_curve));
case JsonWebKeyECCurve::P384:
return CurveID::SECP384R1;
case JsonWebKeyECCurve::P256:
Expand All @@ -105,6 +113,10 @@ namespace ccf::crypto
{
switch (curve_id)
{
case CurveID::NONE:
case CurveID::SECP384R1:
case CurveID::SECP256R1:
throw std::logic_error(fmt::format("Invalid EdDSA curve {}", curve_id));
case CurveID::CURVE25519:
return JsonWebKeyEdDSACurve::ED25519;
case CurveID::X25519:
Expand Down
15 changes: 6 additions & 9 deletions include/ccf/endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,30 +508,27 @@ struct formatter<ccf::endpoints::ForwardingRequired>
auto format(
const ccf::endpoints::ForwardingRequired& v, FormatContext& ctx) const
{
char const* s = nullptr;
switch (v)
{
case ccf::endpoints::ForwardingRequired::Sometimes:
{
s = "sometimes";
break;
return format_to(ctx.out(), "sometimes");
}
case ccf::endpoints::ForwardingRequired::Always:
{
s = "always";
break;
return format_to(ctx.out(), "always");
}
case ccf::endpoints::ForwardingRequired::Never:
{
s = "never";
break;
return format_to(ctx.out(), "never");
}
default:
{
throw std::logic_error("Unhandled value for ForwardingRequired");
throw std::logic_error(fmt::format(
"Unhandled value for ForwardingRequired: {}",
static_cast<uint8_t>(v)));
}
}
return format_to(ctx.out(), "{}", s);
}
};
FMT_END_NAMESPACE
4 changes: 2 additions & 2 deletions include/ccf/pal/attestation_sev_snp.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ pRb21iI1NlNCfOGUPIhVpWECAwEAAQ==
.fmc = tcb.fmc};
}
default:
throw std::logic_error(
"Unsupported SEV-SNP product for TCB version policy");
throw std::logic_error(fmt::format(
"Unsupported SEV-SNP product for TCB version policy: {}", product));
}
}

Expand Down
7 changes: 6 additions & 1 deletion include/ccf/service/tables/proposals.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,18 @@ struct formatter<ccf::ProposalState>
{
return format_to(ctx.out(), "rejected");
}
case (ccf::ProposalState::FAILED):
{
return format_to(ctx.out(), "failed");
}
case (ccf::ProposalState::DROPPED):
{
return format_to(ctx.out(), "dropped");
}
default:
{
return format_to(ctx.out(), "UNKNOWN");
throw std::logic_error(fmt::format(
"Unknown proposal state {}", static_cast<uint8_t>(state)));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion samples/apps/programmability/programmability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ namespace programmabilityapp
"Failed to check if action is original");
return true;
}
default:
case ccf::ApiResult::Uninitialised:
case ccf::ApiResult::NotFound:
{
return true;
}
Expand Down
14 changes: 11 additions & 3 deletions src/consensus/aft/raft.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,9 +799,11 @@ namespace aft
break;
}

case raft_append_entries_signed_response:
default:
{
RAFT_FAIL_FMT("Unhandled AFT message type: {}", type);
RAFT_FAIL_FMT("Received unhandled AFT message type: {}", type);
return;
}
Comment thread
cjen1-msft marked this conversation as resolved.
}
}
Expand Down Expand Up @@ -1444,7 +1446,11 @@ namespace aft
break;
}

default:
case ccf::kv::ApplyResult::PASS_BACKUP_SIGNATURE:
case ccf::kv::ApplyResult::PASS_BACKUP_SIGNATURE_SEND_ACK:
case ccf::kv::ApplyResult::PASS_NONCES:
case ccf::kv::ApplyResult::PASS_NEW_VIEW:
case ccf::kv::ApplyResult::PASS_APPLY:
{
throw std::logic_error("Unknown ApplyResult value");
}
Expand Down Expand Up @@ -2427,7 +2433,9 @@ namespace aft
case ccf::kv::LeadershipState::Candidate:
become_leader();
break;
default:
case ccf::kv::LeadershipState::None:
case ccf::kv::LeadershipState::Leader:
case ccf::kv::LeadershipState::Follower:
throw std::logic_error(
"add_vote_for_me() called while not a pre-vote candidate or "
"candidate");
Expand Down
1 change: 0 additions & 1 deletion src/crypto/openssl/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace ccf::crypto
default:
throw std::runtime_error("Unsupported hash algorithm");
}
return nullptr;
}

std::vector<uint8_t> hkdf(
Expand Down
2 changes: 1 addition & 1 deletion src/ds/actors.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace ccf
{
return "node";
}
default:
case ActorsType::unknown:
{
return "";
}
Expand Down
19 changes: 15 additions & 4 deletions src/enclave/tls_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,11 @@ namespace ccf
break;
}

default:
case closed:
case authfail:
case error:
{
break;
}
}
}
Expand Down Expand Up @@ -435,15 +438,23 @@ namespace ccf
case error:
return;

default:
case handshake:
case ready:
case closing:
{
break;
}
}

status = status_;

switch (status)
{
case handshake:
case ready:
{
break;
}
case closing:
case closed:
{
Expand Down Expand Up @@ -471,8 +482,8 @@ namespace ccf
}

default:
{
}
throw std::logic_error(
fmt::format("TLS {} unknown status: {}", session_id, status));
}
}

Expand Down
33 changes: 31 additions & 2 deletions src/host/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,20 @@ namespace asynchost
{
switch (status)
{
case FRESH:
case BINDING:
case LISTENING_RESOLVING:
case LISTENING:
case CONNECTING_RESOLVING:
case CONNECTING:
case CONNECTED:
case LISTENING_FAILED:
case RECONNECTING:
{
LOG_DEBUG_FMT(
"Unexpected status during reconnect, ignoring: {}", status);
break;
}
case BINDING_FAILED:
{
// Try again, from the start.
Expand Down Expand Up @@ -309,8 +323,8 @@ namespace asynchost

default:
{
LOG_DEBUG_FMT(
"Unexpected status during reconnect, ignoring: {}", status);
throw std::logic_error(
fmt::format("Unexpected status during reconnect: {}", status));
}
}

Expand Down Expand Up @@ -364,6 +378,10 @@ namespace asynchost
break;
}

case FRESH:
case LISTENING_RESOLVING:
case LISTENING:
case LISTENING_FAILED:
default:
{
free_write(req);
Expand Down Expand Up @@ -649,6 +667,17 @@ namespace asynchost
break;
}

case FRESH:
case LISTENING:
case BINDING:
case BINDING_FAILED:
case CONNECTING:
case CONNECTED:
case DISCONNECTED:
case RESOLVING_FAILED:
case LISTENING_FAILED:
case CONNECTING_FAILED:
case RECONNECTING:
default:
{
throw std::logic_error(
Expand Down
2 changes: 1 addition & 1 deletion src/host/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ namespace asynchost
return send_write(req, len, &addr);
}

// This shouldn't happen, but the only state is FRESH
case FRESH:
default:
{
free_write(req);
Expand Down
2 changes: 1 addition & 1 deletion src/http/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ namespace ccf::curl
fmt::format("Unsupported HTTP method: {}", method.c_str()));
}

switch (http_method.value())
switch (static_cast<int>(http_method.value()))
{
case HTTP_GET:
CHECK_CURL_EASY_SETOPT(curl_handle, CURLOPT_HTTPGET, 1L);
Expand Down
2 changes: 1 addition & 1 deletion src/js/permissions_checks.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace ccf::js
{
return KVAccessPermissions::WRITE_ONLY;
}
default:
case (TxAccess::GOV_RO):
{
return KVAccessPermissions::ILLEGAL;
}
Expand Down
7 changes: 5 additions & 2 deletions src/kv/generic_serialise_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ccf/kv/serialisers/serialised_entry.h"
#include "ds/ccf_assert.h"
#include "ds/serialized.h"
#include "kv_types.h"
#include "node/rpc/claims.h"
#include "serialised_entry_format.h"
Expand Down Expand Up @@ -52,8 +53,10 @@ namespace ccf::kv
current_writer = &public_writer;
current_domain = SecurityDomain::PUBLIC;
break;
default:
break;
case SecurityDomain::SECURITY_DOMAIN_MAX:
{
throw std::logic_error("Invalid security domain");
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/node/channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -899,11 +899,19 @@ namespace ccf
return false;
}

case (NodeMsgType::channel_msg):
{
CHANNEL_SEND_FAIL(
"Cannot send channel message on unestablished channel");
return false;
}
Comment thread
cjen1-msft marked this conversation as resolved.

default:
{
CHANNEL_SEND_FAIL(
"Unhandled message type {} on unestablished channel - ignoring",
type);
"Cannot send message of unexpected type {} on unestablished "
"channel",
static_cast<size_t>(type));
return false;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/node/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "service/tables/config.h"
#include "service/tables/signatures.h"

#include <stdexcept>

namespace ccf
{
struct NodeAddr
Expand Down Expand Up @@ -56,6 +58,10 @@ namespace ccf
}
default:
{
throw std::logic_error(fmt::format(
"Unknown node status {} for node {} in configuration change hook",
static_cast<uint8_t>(ni.status),
node_id));
}
}
}
Expand Down
Loading