From c607135a031db727d04cd7078479b00fdb725b42 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Fri, 14 Jan 2022 16:53:28 -0600 Subject: [PATCH] Use fallthrough statement attribute (moar) --- kadmin/rpc.c | 2 +- lib/asn1/gen_copy.c | 2 +- lib/gssapi/krb5/init_sec_context.c | 2 +- lib/hcrypto/libtommath/etc/tune.c | 2 +- lib/hx509/cert.c | 4 ++-- lib/hx509/cms.c | 2 +- lib/hx509/file.c | 2 +- lib/kafs/rxkad_kdf.c | 2 +- lib/krb5/send_to_kdc.c | 4 ++-- lib/ntlm/digest.c | 1 + lib/roken/fnmatch.c | 2 +- lib/roken/getuserinfo.c | 2 +- lib/roken/snprintf.c | 2 +- lib/roken/strftime.c | 2 +- lib/roken/strptime.c | 2 +- lib/wind/utf8.c | 18 +++++++++++------- 16 files changed, 28 insertions(+), 23 deletions(-) diff --git a/kadmin/rpc.c b/kadmin/rpc.c index fcca391fd..162c7e9ce 100644 --- a/kadmin/rpc.c +++ b/kadmin/rpc.c @@ -972,8 +972,8 @@ process_stream(krb5_context contextp, INSIST(gctx.ctx == NULL); gctx.inprogress = 1; - fallthrough /* FALLTHROUGH */ + fallthrough case RPG_CONTINUE_INIT: { gss_name_t src_name = GSS_C_NO_NAME; krb5_data in; diff --git a/lib/asn1/gen_copy.c b/lib/asn1/gen_copy.c index 4c35d334c..37386b797 100644 --- a/lib/asn1/gen_copy.c +++ b/lib/asn1/gen_copy.c @@ -62,8 +62,8 @@ copy_type (const char *from, const char *to, const Type *t, int preserve) copy_primitive ("heim_integer", from, to); break; } - fallthrough /* FALLTHROUGH */ + fallthrough case TBoolean: case TEnumerated : fprintf(codefile, "*(%s) = *(%s);\n", to, from); diff --git a/lib/gssapi/krb5/init_sec_context.c b/lib/gssapi/krb5/init_sec_context.c index 8eb5b629b..fdc81ad6c 100644 --- a/lib/gssapi/krb5/init_sec_context.c +++ b/lib/gssapi/krb5/init_sec_context.c @@ -929,8 +929,8 @@ OM_uint32 GSSAPI_CALLCONV _gsskrb5_init_sec_context time_rec); if (ret != GSS_S_COMPLETE) break; - fallthrough /* FALLTHROUGH */ + fallthrough case INITIATOR_RESTART: ret = init_auth_restart(minor_status, cred, diff --git a/lib/hcrypto/libtommath/etc/tune.c b/lib/hcrypto/libtommath/etc/tune.c index 098d0412f..04ba08fc1 100644 --- a/lib/hcrypto/libtommath/etc/tune.c +++ b/lib/hcrypto/libtommath/etc/tune.c @@ -424,8 +424,8 @@ int main(int argc, char **argv) break; case 'h': s_exit_code = EXIT_SUCCESS; - fallthrough /* FALLTHROUGH */ + fallthrough default: s_usage(argv[0]); } diff --git a/lib/hx509/cert.c b/lib/hx509/cert.c index ec44e9108..b176b6caa 100644 --- a/lib/hx509/cert.c +++ b/lib/hx509/cert.c @@ -2438,12 +2438,12 @@ hx509_verify_path(hx509_context context, * EE checking below. */ type = EE_CERT; - fallthrough /* FALLTHROUGH */ + fallthrough } - fallthrough } /* FALLTHROUGH */ + fallthrough case EE_CERT: /* * If there where any proxy certificates in the chain diff --git a/lib/hx509/cms.c b/lib/hx509/cms.c index 30e4b4e34..c38c2b98d 100644 --- a/lib/hx509/cms.c +++ b/lib/hx509/cms.c @@ -182,8 +182,8 @@ fill_CMSIdentifier(const hx509_cert cert, &id->u.subjectKeyIdentifier); if (ret == 0) break; - fallthrough /* FALLTHROUGH */ + fallthrough case CMS_ID_NAME: { hx509_name name; diff --git a/lib/hx509/file.c b/lib/hx509/file.c index 877fb1d48..0090b035b 100644 --- a/lib/hx509/file.c +++ b/lib/hx509/file.c @@ -230,8 +230,8 @@ hx509_pem_read(hx509_context context, where = INDATA; goto indata; } - fallthrough /* FALLTHROUGH */ + fallthrough case INHEADER: if (buf[0] == '\0') { where = INDATA; diff --git a/lib/kafs/rxkad_kdf.c b/lib/kafs/rxkad_kdf.c index 351f6f87a..1254939f5 100644 --- a/lib/kafs/rxkad_kdf.c +++ b/lib/kafs/rxkad_kdf.c @@ -209,8 +209,8 @@ _kafs_derive_des_key(krb5_enctype enctype, void *keydata, size_t keylen, ret = compress_parity_bits(keydata, &keylen); if (ret) return ret; - fallthrough /* FALLTHROUGH */ + fallthrough default: if (enctype < 0) return KRB5_PROG_ETYPE_NOSUPP; diff --git a/lib/krb5/send_to_kdc.c b/lib/krb5/send_to_kdc.c index 40118f053..c524cb16e 100644 --- a/lib/krb5/send_to_kdc.c +++ b/lib/krb5/send_to_kdc.c @@ -1192,8 +1192,8 @@ krb5_sendto_context(krb5_context context, break; } action = KRB5_SENDTO_KRBHST; - fallthrough /* FALLTHROUGH */ + fallthrough case KRB5_SENDTO_KRBHST: if (ctx->krbhst == NULL) { ret = krb5_krbhst_init_flags(context, realm, type, @@ -1215,8 +1215,8 @@ krb5_sendto_context(krb5_context context, handle = heim_retain(ctx->krbhst); } action = KRB5_SENDTO_TIMEOUT; - fallthrough /* FALLTHROUGH */ + fallthrough case KRB5_SENDTO_TIMEOUT: /* diff --git a/lib/ntlm/digest.c b/lib/ntlm/digest.c index a1d6b5f3a..0d4935feb 100644 --- a/lib/ntlm/digest.c +++ b/lib/ntlm/digest.c @@ -472,6 +472,7 @@ heim_digest_generate_challenge(heim_digest_t context) case HEIM_DIGEST_TYPE_AUTO: context->type = HEIM_DIGEST_TYPE_RFC2831; /* FALLTHROUGH */ + fallthrough case HEIM_DIGEST_TYPE_RFC2831: asprintf(&challenge, "realm=\"%s\",nonce=\"%s\",qop=\"%s\",algorithm=md5-sess,charset=utf-8,maxbuf=%s", context->serverRealm, context->serverNonce, context->serverQOP, context->serverMaxbuf); diff --git a/lib/roken/fnmatch.c b/lib/roken/fnmatch.c index ff1b0dbd8..d8ae6ce4e 100644 --- a/lib/roken/fnmatch.c +++ b/lib/roken/fnmatch.c @@ -129,8 +129,8 @@ rk_fnmatch(const char *pattern, const char *string, int flags) --pattern; } } - fallthrough /* FALLTHROUGH */ + fallthrough default: if (c != *string++) return (FNM_NOMATCH); diff --git a/lib/roken/getuserinfo.c b/lib/roken/getuserinfo.c index b1bda23a2..9980c247b 100644 --- a/lib/roken/getuserinfo.c +++ b/lib/roken/getuserinfo.c @@ -136,8 +136,8 @@ roken_get_homedir(char *home, size_t homesz) } return home; } - fallthrough /* FALLTHROUGH */ + fallthrough #else #ifdef HAVE_GETPWNAM_R size_t buflen = 2048; diff --git a/lib/roken/snprintf.c b/lib/roken/snprintf.c index f1daa0f33..312ee7329 100644 --- a/lib/roken/snprintf.c +++ b/lib/roken/snprintf.c @@ -515,8 +515,8 @@ xyzprintf (struct snprintf_state *state, const char *char_format, va_list ap) } case '\0' : --format; - fallthrough /* FALLTHROUGH */ + fallthrough case '%' : (*state->append_char)(state, c); ++len; diff --git a/lib/roken/strftime.c b/lib/roken/strftime.c index d2ba66972..36f7dc1ef 100644 --- a/lib/roken/strftime.c +++ b/lib/roken/strftime.c @@ -377,8 +377,8 @@ strftime (char *buf, size_t maxsize, const char *format, break; case '\0' : --format; - fallthrough /* FALLTHROUGH */ + fallthrough case '%' : ret = snprintf (buf, maxsize - n, "%%"); diff --git a/lib/roken/strptime.c b/lib/roken/strptime.c index bb1b27d7c..118091a97 100644 --- a/lib/roken/strptime.c +++ b/lib/roken/strptime.c @@ -424,8 +424,8 @@ strptime (const char *buf, const char *format, struct tm *timeptr) abort (); case '\0' : --format; - fallthrough /* FALLTHROUGH */ + fallthrough case '%' : if (*buf == '%') ++buf; diff --git a/lib/wind/utf8.c b/lib/wind/utf8.c index 1ab83a131..3358a93aa 100644 --- a/lib/wind/utf8.c +++ b/lib/wind/utf8.c @@ -205,22 +205,24 @@ wind_ucs4utf8(const uint32_t *in, size_t in_len, char *out, size_t *out_len) case 4: out[3] = (ch | 0x80) & 0xbf; ch = ch >> 6; - fallthrough /* FALLTHROUGH */ + fallthrough case 3: out[2] = (ch | 0x80) & 0xbf; ch = ch >> 6; - fallthrough /* FALLTHROUGH */ + fallthrough case 2: out[1] = (ch | 0x80) & 0xbf; ch = ch >> 6; - fallthrough /* FALLTHROUGH */ + fallthrough case 1: out[0] = ch | first_char[len - 1]; - fallthrough /* FALLTHROUGH */ + fallthrough + default: + break; } } out += len; @@ -488,17 +490,19 @@ wind_ucs2utf8(const uint16_t *in, size_t in_len, char *out, size_t *out_len) case 3: out[2] = (ch | 0x80) & 0xbf; ch = ch >> 6; - fallthrough /* FALLTHROUGH */ + fallthrough case 2: out[1] = (ch | 0x80) & 0xbf; ch = ch >> 6; - fallthrough /* FALLTHROUGH */ + fallthrough case 1: out[0] = ch | first_char[len - 1]; - fallthrough /* FALLTHROUGH */ + fallthrough + default: + break; } out += len; }