Commit f3b3d7f0 authored by Rich Salz's avatar Rich Salz
Browse files

Add -Wswitch-enum



Change code so when switching on an enumeration, have case's for all
enumeration values.

Reviewed-by: default avatarAndy Polyakov <appro@openssl.org>
parent 39c136cc
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ my $gcc_devteam_warn = "-DDEBUG_UNUSED"
        # 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"
@@ -127,7 +128,6 @@ my $gcc_devteam_warn = "-DDEBUG_UNUSED"
# 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()
@@ -136,6 +136,7 @@ my $gcc_devteam_warn = "-DDEBUG_UNUSED"
my $clang_devteam_warn = ""
        . " -Qunused-arguments"
        . " -Wextra"
        . " -Wswitch -Wswitch-default"
        . " -Wno-unused-parameter"
        . " -Wno-missing-field-initializers"
        . " -Wno-language-extension-token"
+10 −2
Original line number Diff line number Diff line
@@ -188,7 +188,11 @@ static int ui_read(UI *ui, UI_STRING *uis)
                    return 1;
                }
            }
        default:
            break;
        case UIT_NONE:
        case UIT_BOOLEAN:
        case UIT_INFO:
        case UIT_ERROR:
            break;
        }
    }
@@ -208,7 +212,11 @@ static int ui_write(UI *ui, UI_STRING *uis)
                if (password && password[0] != '\0')
                    return 1;
            }
        default:
            break;
        case UIT_NONE:
        case UIT_BOOLEAN:
        case UIT_INFO:
        case UIT_ERROR:
            break;
        }
    }
+11 −5
Original line number Diff line number Diff line
@@ -393,26 +393,32 @@ int list_main(int argc, char **argv)
    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;
        }
+6 −9
Original line number Diff line number Diff line
@@ -296,19 +296,14 @@ int ts_main(int argc, char **argv)
        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))
@@ -320,13 +315,15 @@ int ts_main(int argc, char **argv)
        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:
+2 −2
Original line number Diff line number Diff line
@@ -157,7 +157,6 @@ static int asn1_bio_write(BIO *b, const char *in, int inl)

    for (;;) {
        switch (ctx->state) {

            /* Setup prefix data, call it */
        case ASN1_STATE_START:
            if (!asn1_bio_setup_ex(b, ctx, ctx->prefix,
@@ -223,7 +222,8 @@ static int asn1_bio_write(BIO *b, const char *in, int inl)

            break;

        default:
        case ASN1_STATE_POST_COPY:
        case ASN1_STATE_DONE:
            BIO_clear_retry_flags(b);
            return 0;

Loading