# it grew impossible to resolve this without sizeable additional
# code, so we just tell compiler to be pedantic about everything
# but 'long long' type.
+ . " -Wswitch"
. " -DPEDANTIC -pedantic -Wno-long-long"
. " -Wall"
. " -Wsign-compare"
# These are used in addition to $gcc_devteam_warn when the compiler is clang.
# TODO(openssl-team): fix problems and investigate if (at least) the
# following warnings can also be enabled:
-# -Wswitch-enum
# -Wcast-align
# -Wunreachable-code
# -Wlanguage-extension-token -- no, we use asm()
my $clang_devteam_warn = ""
. " -Qunused-arguments"
. " -Wextra"
+ . " -Wswitch -Wswitch-default"
. " -Wno-unused-parameter"
. " -Wno-missing-field-initializers"
. " -Wno-language-extension-token"
return 1;
}
}
- default:
+ break;
+ case UIT_NONE:
+ case UIT_BOOLEAN:
+ case UIT_INFO:
+ case UIT_ERROR:
break;
}
}
if (password && password[0] != '\0')
return 1;
}
- default:
+ break;
+ case UIT_NONE:
+ case UIT_BOOLEAN:
+ case UIT_INFO:
+ case UIT_ERROR:
break;
}
}
return 0;
}
+typedef enum HELP_CHOICE {
+ OPT_hERR = -1, OPT_hEOF = 0, OPT_hHELP
+} HELP_CHOICE;
+
OPTIONS help_options[] = {
- {"help", OPT_HELP, '-', "Display this summary"},
+ {"help", OPT_hHELP, '-', "Display this summary"},
{NULL}
};
+
int help_main(int argc, char **argv)
{
FUNCTION *fp;
int i, nl;
FUNC_TYPE tp;
char *prog;
- HELPLIST_CHOICE o;
+ HELP_CHOICE o;
prog = opt_init(argc, argv, help_options);
- while ((o = opt_next()) != OPT_EOF) {
+ while ((o = opt_next()) != OPT_hEOF) {
switch (o) {
- default:
+ case OPT_hERR:
+ case OPT_hEOF:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
return 1;
- case OPT_HELP:
+ case OPT_hHELP:
opt_help(help_options);
return 0;
}
goto end;
/* Check parameter consistency and execute the appropriate function. */
- switch (mode) {
- default:
- case OPT_ERR:
- goto opthelp;
- case OPT_QUERY:
+ if (mode == OPT_QUERY) {
if (vpmtouched)
goto opthelp;
if ((data != NULL) && (digest != NULL))
goto opthelp;
ret = !query_command(data, digest, md, policy, no_nonce, cert,
in, out, text);
- break;
- case OPT_REPLY:
+ } else if (mode == OPT_REPLY) {
if (vpmtouched)
goto opthelp;
if ((in != NULL) && (queryfile != NULL))
ret = !reply_command(conf, section, engine, queryfile,
password, inkey, md, signer, chain, policy,
in, token_in, out, token_out, text);
- break;
- case OPT_VERIFY:
+
+ } else if (mode == OPT_VERIFY) {
if ((in == NULL) || !EXACTLY_ONE(queryfile, data, digest))
goto opthelp;
ret = !verify_command(data, digest, queryfile, in, token_in,
CApath, CAfile, untrusted,
vpmtouched ? vpm : NULL);
+ } else {
+ goto opthelp;
}
end:
for (;;) {
switch (ctx->state) {
-
/* Setup prefix data, call it */
case ASN1_STATE_START:
if (!asn1_bio_setup_ex(b, ctx, ctx->prefix,
break;
- default:
+ case ASN1_STATE_POST_COPY:
+ case ASN1_STATE_DONE:
BIO_clear_retry_flags(b);
return 0;
case CT_LOG_ENTRY_TYPE_PRECERT:
sct->entry_type = entry_type;
return 1;
- default:
- CTerr(CT_F_SCT_SET_LOG_ENTRY_TYPE, CT_R_UNSUPPORTED_ENTRY_TYPE);
- return 0;
+ case CT_LOG_ENTRY_TYPE_NOT_SET:
+ break;
}
+ CTerr(CT_F_SCT_SET_LOG_ENTRY_TYPE, CT_R_UNSUPPORTED_ENTRY_TYPE);
+ return 0;
}
int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len)
return SCT_set_log_entry_type(sct, CT_LOG_ENTRY_TYPE_X509);
case SCT_SOURCE_X509V3_EXTENSION:
return SCT_set_log_entry_type(sct, CT_LOG_ENTRY_TYPE_PRECERT);
- default: /* if we aren't sure, leave the log entry type alone */
- return 1;
+ case SCT_SOURCE_UNKNOWN:
+ break;
}
+ /* if we aren't sure, leave the log entry type alone */
+ return 1;
}
sct_validation_status_t SCT_get_validation_status(const SCT *sct)
void EC_pre_comp_free(EC_GROUP *group)
{
switch (group->pre_comp_type) {
- default:
+ case PCT_none:
break;
-#ifdef ECP_NISTZ256_REFERENCE_IMPLEMENTATION
case PCT_nistz256:
+#ifdef ECP_NISTZ256_ASM
EC_nistz256_pre_comp_free(group->pre_comp.nistz256);
- break;
#endif
+ break;
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
case PCT_nistp224:
EC_nistp224_pre_comp_free(group->pre_comp.nistp224);
case PCT_nistp521:
EC_nistp521_pre_comp_free(group->pre_comp.nistp521);
break;
+#else
+ case PCT_nistp224:
+ case PCT_nistp256:
+ case PCT_nistp521:
+ break;
#endif
case PCT_ec:
EC_ec_pre_comp_free(group->pre_comp.ec);
/* Copy precomputed */
dest->pre_comp_type = src->pre_comp_type;
switch (src->pre_comp_type) {
- default:
+ case PCT_none:
dest->pre_comp.ec = NULL;
break;
-#ifdef ECP_NISTZ256_REFERENCE_IMPLEMENTATION
case PCT_nistz256:
+#ifdef ECP_NISTZ256_ASM
dest->pre_comp.nistz256 = EC_nistz256_pre_comp_dup(src->pre_comp.nistz256);
- break;
#endif
+ break;
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
case PCT_nistp224:
dest->pre_comp.nistp224 = EC_nistp224_pre_comp_dup(src->pre_comp.nistp224);
case PCT_nistp521:
dest->pre_comp.nistp521 = EC_nistp521_pre_comp_dup(src->pre_comp.nistp521);
break;
+#else
+ case PCT_nistp224:
+ case PCT_nistp256:
+ case PCT_nistp521:
+ break;
#endif
case PCT_ec:
dest->pre_comp.ec = EC_ec_pre_comp_dup(src->pre_comp.ec);
return res;
}
+/*
+ * For reference, this macro is used only when new ecp_nistz256 assembly
+ * module is being developed. For example, configure with
+ * -DECP_NISTZ256_REFERENCE_IMPLEMENTATION and implement only functions
+ * performing simplest arithmetic operations on 256-bit vectors. Then
+ * work on implementation of higher-level functions performing point
+ * operations. Then remove ECP_NISTZ256_REFERENCE_IMPLEMENTATION
+ * and never define it again. (The correct macro denoting presence of
+ * ecp_nistz256 module is ECP_NISTZ256_ASM.)
+ */
#ifndef ECP_NISTZ256_REFERENCE_IMPLEMENTATION
void ecp_nistz256_point_double(P256_POINT *r, const P256_POINT *a);
void ecp_nistz256_point_add(P256_POINT *r,
OPENSSL_free((char *)uis->_.boolean_data.ok_chars);
OPENSSL_free((char *)uis->_.boolean_data.cancel_chars);
break;
- default:
+ case UIT_NONE:
+ case UIT_PROMPT:
+ case UIT_VERIFY:
+ case UIT_ERROR:
+ case UIT_INFO:
break;
}
}
case UIT_PROMPT:
case UIT_BOOLEAN:
return uis->_.boolean_data.action_desc;
- default:
- return NULL;
+ case UIT_NONE:
+ case UIT_VERIFY:
+ case UIT_INFO:
+ case UIT_ERROR:
+ break;
}
+ return NULL;
}
const char *UI_get0_result_string(UI_STRING *uis)
case UIT_PROMPT:
case UIT_VERIFY:
return uis->result_buf;
- default:
- return NULL;
+ case UIT_NONE:
+ case UIT_BOOLEAN:
+ case UIT_INFO:
+ case UIT_ERROR:
+ break;
}
+ return NULL;
}
const char *UI_get0_test_string(UI_STRING *uis)
switch (uis->type) {
case UIT_VERIFY:
return uis->_.string_data.test_buf;
- default:
- return NULL;
+ case UIT_NONE:
+ case UIT_BOOLEAN:
+ case UIT_INFO:
+ case UIT_ERROR:
+ case UIT_PROMPT:
+ break;
}
+ return NULL;
}
int UI_get_result_minsize(UI_STRING *uis)
case UIT_PROMPT:
case UIT_VERIFY:
return uis->_.string_data.result_minsize;
- default:
- return -1;
+ case UIT_NONE:
+ case UIT_INFO:
+ case UIT_ERROR:
+ case UIT_BOOLEAN:
+ break;
}
+ return -1;
}
int UI_get_result_maxsize(UI_STRING *uis)
case UIT_PROMPT:
case UIT_VERIFY:
return uis->_.string_data.result_maxsize;
- default:
- return -1;
+ case UIT_NONE:
+ case UIT_INFO:
+ case UIT_ERROR:
+ case UIT_BOOLEAN:
+ break;
}
+ return -1;
}
int UI_set_result(UI *ui, UI_STRING *uis, const char *result)
}
}
}
- default:
+ case UIT_NONE:
+ case UIT_INFO:
+ case UIT_ERROR:
break;
}
return 0;
fputs(UI_get0_output_string(uis), tty_out);
fflush(tty_out);
break;
- default:
+ case UIT_NONE:
+ case UIT_PROMPT:
+ case UIT_VERIFY:
+ case UIT_BOOLEAN:
break;
}
return 1;
return 0;
}
break;
- default:
+ case UIT_NONE:
+ case UIT_INFO:
+ case UIT_ERROR:
break;
}
return 1;
case X509_LU_CRL:
ret = X509_CRL_cmp((*a)->data.crl, (*b)->data.crl);
break;
- default:
+ case X509_LU_NONE:
/* abort(); */
return 0;
}
int X509_OBJECT_up_ref_count(X509_OBJECT *a)
{
switch (a->type) {
- default:
+ case X509_LU_NONE:
break;
case X509_LU_X509:
return X509_up_ref(a->data.x509);
if (a == NULL)
return;
switch (a->type) {
- default:
+ case X509_LU_NONE:
break;
case X509_LU_X509:
X509_free(a->data.x509);
stmp.data.crl = &crl_s;
crl_s.crl.issuer = name;
break;
- default:
+ case X509_LU_NONE:
/* abort(); */
return -1;
}
case READ_STATE_POST_PROCESS:
st->read_state_work = post_process_message(s, st->read_state_work);
switch (st->read_state_work) {
- default:
+ case WORK_ERROR:
+ case WORK_MORE_A:
+ case WORK_MORE_B:
return SUB_STATE_ERROR;
case WORK_FINISHED_CONTINUE:
return SUB_STATE_FINISHED;
break;
- default:
+ case WRITE_TRAN_ERROR:
return SUB_STATE_ERROR;
}
break;
case WRITE_STATE_PRE_WORK:
switch (st->write_state_work = pre_work(s, st->write_state_work)) {
- default:
+ case WORK_ERROR:
+ case WORK_MORE_A:
+ case WORK_MORE_B:
return SUB_STATE_ERROR;
case WORK_FINISHED_CONTINUE:
case WRITE_STATE_POST_WORK:
switch (st->write_state_work = post_work(s, st->write_state_work)) {
- default:
+ case WORK_ERROR:
+ case WORK_MORE_A:
+ case WORK_MORE_B:
return SUB_STATE_ERROR;
case WORK_FINISHED_CONTINUE:
int ske_expected;
switch (st->hand_state) {
+ default:
+ break;
+
case TLS_ST_CW_CLNT_HELLO:
if (mt == SSL3_MT_SERVER_HELLO) {
st->hand_state = TLS_ST_CR_SRVR_HELLO;
return 1;
}
break;
-
- default:
- break;
}
err:
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return WRITE_TRAN_ERROR;
+
case TLS_ST_OK:
/* Renegotiation - fall through */
case TLS_ST_BEFORE:
ossl_statem_set_in_init(s, 0);
return WRITE_TRAN_CONTINUE;
}
-
- default:
- /* Shouldn't happen */
- return WRITE_TRAN_ERROR;
}
}
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* No pre work to be done */
+ break;
+
case TLS_ST_CW_CLNT_HELLO:
s->shutdown = 0;
if (SSL_IS_DTLS(s)) {
return dtls_wait_for_dry(s);
#endif
}
- return WORK_FINISHED_CONTINUE;
+ break;
case TLS_ST_OK:
return tls_finish_handshake(s, wst);
-
- default:
- /* No pre work to be done */
- break;
}
return WORK_FINISHED_CONTINUE;
s->init_num = 0;
switch (st->hand_state) {
+ default:
+ /* No post work to be done */
+ break;
+
case TLS_ST_CW_CLNT_HELLO:
if (wst == WORK_MORE_A && statem_flush(s) != 1)
return WORK_MORE_A;
if (statem_flush(s) != 1)
return WORK_MORE_B;
break;
-
- default:
- /* No post work to be done */
- break;
}
return WORK_FINISHED_CONTINUE;
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return 0;
+
case TLS_ST_CW_CLNT_HELLO:
return tls_construct_client_hello(s);
ssl3_enc->client_finished_label,
s->method->
ssl3_enc->client_finished_label_len);
-
- default:
- /* Shouldn't happen */
- break;
}
-
- return 0;
}
/*
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return 0;
+
case TLS_ST_CR_SRVR_HELLO:
return SERVER_HELLO_MAX_LENGTH;
case TLS_ST_CR_FINISHED:
return FINISHED_MAX_LENGTH;
-
- default:
- /* Shouldn't happen */
- break;
}
-
- return 0;
}
/*
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return MSG_PROCESS_ERROR;
+
case TLS_ST_CR_SRVR_HELLO:
return tls_process_server_hello(s, pkt);
case TLS_ST_CR_FINISHED:
return tls_process_finished(s, pkt);
-
- default:
- /* Shouldn't happen */
- break;
}
-
- return MSG_PROCESS_ERROR;
}
/*
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return WORK_ERROR;
+
case TLS_ST_CR_CERT_REQ:
return tls_prepare_client_certificate(s, wst);
ossl_statem_set_sctp_read_sock(s, 0);
return WORK_FINISHED_STOP;
#endif
-
- default:
- break;
}
-
- /* Shouldn't happen */
- return WORK_ERROR;
}
int tls_construct_client_hello(SSL *s)
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ break;
+
case TLS_ST_BEFORE:
case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
if (mt == SSL3_MT_CLIENT_HELLO) {
return 1;
}
break;
-
- default:
- break;
}
/* No valid transition found */
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return WRITE_TRAN_ERROR;
+
case TLS_ST_BEFORE:
/* Just go straight to trying to read from the client */
return WRITE_TRAN_FINISHED;
st->hand_state = TLS_ST_OK;
ossl_statem_set_in_init(s, 0);
return WRITE_TRAN_CONTINUE;
-
- default:
- /* Shouldn't happen */
- return WRITE_TRAN_ERROR;
}
}
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* No pre work to be done */
+ break;
+
case TLS_ST_SW_HELLO_REQ:
s->shutdown = 0;
if (SSL_IS_DTLS(s))
case TLS_ST_OK:
return tls_finish_handshake(s, wst);
-
- default:
- /* No pre work to be done */
- break;
}
return WORK_FINISHED_CONTINUE;
s->init_num = 0;
switch (st->hand_state) {
+ default:
+ /* No post work to be done */
+ break;
+
case TLS_ST_SW_HELLO_REQ:
if (statem_flush(s) != 1)
return WORK_MORE_A;
}
#endif
break;
-
- default:
- /* No post work to be done */
- break;
}
return WORK_FINISHED_CONTINUE;
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return 0;
+
case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
return dtls_construct_hello_verify_request(s);
ssl3_enc->server_finished_label,
s->method->
ssl3_enc->server_finished_label_len);
-
- default:
- /* Shouldn't happen */
- break;
}
-
- return 0;
}
/*
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return 0;
+
case TLS_ST_SR_CLNT_HELLO:
return CLIENT_HELLO_MAX_LENGTH;
case TLS_ST_SR_FINISHED:
return FINISHED_MAX_LENGTH;
-
- default:
- /* Shouldn't happen */
- break;
}
-
- return 0;
}
/*
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return MSG_PROCESS_ERROR;
+
case TLS_ST_SR_CLNT_HELLO:
return tls_process_client_hello(s, pkt);
case TLS_ST_SR_FINISHED:
return tls_process_finished(s, pkt);
-
- default:
- /* Shouldn't happen */
- break;
}
-
- return MSG_PROCESS_ERROR;
}
/*
OSSL_STATEM *st = &s->statem;
switch (st->hand_state) {
+ default:
+ /* Shouldn't happen */
+ return WORK_ERROR;
+
case TLS_ST_SR_CLNT_HELLO:
return tls_post_process_client_hello(s, wst);
}
#endif
return WORK_FINISHED_CONTINUE;
-
- default:
- break;
}
- /* Shouldn't happen */
- return WORK_ERROR;
}
#ifndef OPENSSL_NO_SRP
case SCT_VALIDATION_STATUS_INVALID:
++invalid_sct_count;
break;
- default:
+ case SCT_VALIDATION_STATUS_NOT_SET:
+ case SCT_VALIDATION_STATUS_UNKNOWN_LOG:
+ case SCT_VALIDATION_STATUS_UNVERIFIED:
+ case SCT_VALIDATION_STATUS_UNKNOWN_VERSION:
/* Ignore other validation statuses. */
break;
}
SSL_CTX_set_cert_verify_callback(client_ctx, &verify_reject_cb,
NULL);
break;
- default:
+ case SSL_TEST_VERIFY_NONE:
break;
}
SSL_CTX_set_tlsext_servername_callback(server_ctx, servername_reject_cb);
SSL_CTX_set_tlsext_servername_arg(server_ctx, server2_ctx);
break;
- default:
+ case SSL_TEST_SERVERNAME_CB_NONE:
break;
}
return SHUTDOWN;
case SHUTDOWN:
return CONNECTION_DONE;
- default:
- TEST_check(0); /* Should never call next_phase when done. */
+ case CONNECTION_DONE:
+ TEST_check(0);
+ break;
}
+ return -1;
}
static void do_connect_step(PEER *peer, connect_phase_t phase)
case SHUTDOWN:
do_shutdown_step(peer);
break;
- default:
+ case CONNECTION_DONE:
TEST_check(0);
+ break;
}
}