diff --git a/configure.ac b/configure.ac index 8c0b746ba..b946dfff4 100644 --- a/configure.ac +++ b/configure.ac @@ -505,16 +505,20 @@ rk_WIN32_EXPORT(BUILD_ROKEN_LIB, ROKEN_LIB) rk_WIN32_EXPORT(BUILD_GSSAPI_LIB, GSSAPI_LIB) rk_WIN32_EXPORT(BUILD_KDC_LIB, KDC_LIB) -dnl Deal with switch FALLTHROUGH +dnl Deal with switch fallthrough warnings AH_TOP([ -#if defined(__GNUC__) -#if __GNUC__ >= 7 -# define fallthrough __attribute__((fallthrough)) +#if defined(DISPATCH_FALLTHROUGH) +# define HEIM_FALLTHROUGH DISPATCH_FALLTHROUGH #else -# define fallthrough do {} while (0) /* fallthrough */ -#endif -#else -# define fallthrough do {} while (0) /* fallthrough */ +# if defined(__GNUC__) +# if __GNUC__ >= 7 +# define HEIM_FALLTHROUGH __attribute__((fallthrough)) +# else +# define HEIM_FALLTHROUGH do {} while (0) /* fallthrough */ +# endif +# else +# define HEIM_FALLTHROUGH do {} while (0) /* fallthrough */ +# endif #endif ]) diff --git a/include/config.h.w32 b/include/config.h.w32 index 5521181d2..6e0f6bcf1 100644 --- a/include/config.h.w32 +++ b/include/config.h.w32 @@ -26,13 +26,13 @@ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. - * + * **********************************************************************/ #ifndef __CONFIG_H__ #define __CONFIG_H__ -#define fallthrough do {} while(0) /* fallthrough */ +#define HEIM_FALLTHROUGH do {} while(0) /* fallthrough */ #ifndef RCSID #define RCSID(msg) \ diff --git a/kadmin/rpc.c b/kadmin/rpc.c index 1ae10f1af..5cae3d2c2 100644 --- a/kadmin/rpc.c +++ b/kadmin/rpc.c @@ -972,7 +972,7 @@ process_stream(krb5_context contextp, INSIST(gctx.ctx == NULL); gctx.inprogress = 1; - fallthrough; + HEIM_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 bec6f8b05..c6d420a2f 100644 --- a/lib/asn1/gen_copy.c +++ b/lib/asn1/gen_copy.c @@ -62,7 +62,7 @@ copy_type (const char *from, const char *to, const Type *t, int preserve) copy_primitive ("heim_integer", from, to); break; } - fallthrough; + HEIM_FALLTHROUGH; case TBoolean: case TEnumerated : fprintf(codefile, "*(%s) = *(%s);\n", to, from); diff --git a/lib/asn1/gen_free.c b/lib/asn1/gen_free.c index 0507d5421..53b7bfe7b 100644 --- a/lib/asn1/gen_free.c +++ b/lib/asn1/gen_free.c @@ -56,7 +56,7 @@ free_type (const char *name, const Type *t, int preserve) free_primitive ("heim_integer", name); break; } - /* fallthrough; */ + /* HEIM_FALLTHROUGH; */ case TBoolean: case TEnumerated : case TNull: diff --git a/lib/gssapi/krb5/init_sec_context.c b/lib/gssapi/krb5/init_sec_context.c index 62b26ed7e..a705d03a8 100644 --- a/lib/gssapi/krb5/init_sec_context.c +++ b/lib/gssapi/krb5/init_sec_context.c @@ -932,7 +932,7 @@ OM_uint32 GSSAPI_CALLCONV _gsskrb5_init_sec_context time_rec); if (ret != GSS_S_COMPLETE) break; - fallthrough; + HEIM_FALLTHROUGH; case INITIATOR_RESTART: ret = init_auth_restart(minor_status, cred, diff --git a/lib/hx509/cert.c b/lib/hx509/cert.c index 656a13872..4fce8f21a 100644 --- a/lib/hx509/cert.c +++ b/lib/hx509/cert.c @@ -2441,10 +2441,10 @@ hx509_verify_path(hx509_context context, * EE checking below. */ type = EE_CERT; - fallthrough; + HEIM_FALLTHROUGH; } } - fallthrough; + HEIM_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 d2728a38c..c770b8132 100644 --- a/lib/hx509/cms.c +++ b/lib/hx509/cms.c @@ -182,7 +182,7 @@ fill_CMSIdentifier(const hx509_cert cert, &id->u.subjectKeyIdentifier); if (ret == 0) break; - fallthrough; + HEIM_FALLTHROUGH; case CMS_ID_NAME: { hx509_name name; diff --git a/lib/hx509/file.c b/lib/hx509/file.c index a22f6252c..e1fbe7c06 100644 --- a/lib/hx509/file.c +++ b/lib/hx509/file.c @@ -230,7 +230,7 @@ hx509_pem_read(hx509_context context, where = INDATA; goto indata; } - fallthrough; + HEIM_FALLTHROUGH; case INHEADER: if (buf[0] == '\0') { where = INDATA; diff --git a/lib/hx509/req.c b/lib/hx509/req.c index 2b3f46d53..c8fa42e5f 100644 --- a/lib/hx509/req.c +++ b/lib/hx509/req.c @@ -1046,7 +1046,7 @@ authorize_feat(hx509_request req, abitstring a, size_t n, int idx) switch (ret) { case 0: req->nauthorized++; - fallthrough; + HEIM_FALLTHROUGH; case -1: return 0; default: @@ -1063,7 +1063,7 @@ reject_feat(hx509_request req, abitstring a, size_t n, int idx) switch (ret) { case 0: req->nauthorized--; - fallthrough; + HEIM_FALLTHROUGH; case -1: return 0; default: @@ -1245,7 +1245,7 @@ san_map_type(GeneralName *san) if (der_heim_oid_cmp(&san->u.otherName.type_id, map[i].oid) == 0) return map[i].type; } - fallthrough; + HEIM_FALLTHROUGH; default: return HX509_SAN_TYPE_UNSUPPORTED; } } @@ -1360,7 +1360,7 @@ hx509_request_get_san(hx509_request req, case HX509_SAN_TYPE_REGISTERED_ID: return der_print_heim_oid(&san->u.registeredID, '.', out); case HX509_SAN_TYPE_XMPP: - fallthrough; + HEIM_FALLTHROUGH; case HX509_SAN_TYPE_MS_UPN: { int ret; diff --git a/lib/kafs/rxkad_kdf.c b/lib/kafs/rxkad_kdf.c index 5af391ed9..b542e8916 100644 --- a/lib/kafs/rxkad_kdf.c +++ b/lib/kafs/rxkad_kdf.c @@ -209,7 +209,7 @@ _kafs_derive_des_key(krb5_enctype enctype, void *keydata, size_t keylen, ret = compress_parity_bits(keydata, &keylen); if (ret) return ret; - fallthrough; + HEIM_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 086f2edcd..a854e5c4a 100644 --- a/lib/krb5/send_to_kdc.c +++ b/lib/krb5/send_to_kdc.c @@ -1192,7 +1192,7 @@ krb5_sendto_context(krb5_context context, break; } action = KRB5_SENDTO_KRBHST; - fallthrough; + HEIM_FALLTHROUGH; case KRB5_SENDTO_KRBHST: if (ctx->krbhst == NULL) { ret = krb5_krbhst_init_flags(context, realm, type, @@ -1214,7 +1214,7 @@ krb5_sendto_context(krb5_context context, handle = heim_retain(ctx->krbhst); } action = KRB5_SENDTO_TIMEOUT; - fallthrough; + HEIM_FALLTHROUGH; case KRB5_SENDTO_TIMEOUT: /* diff --git a/lib/ntlm/digest.c b/lib/ntlm/digest.c index 761e1f497..42c39ff23 100644 --- a/lib/ntlm/digest.c +++ b/lib/ntlm/digest.c @@ -471,7 +471,7 @@ heim_digest_generate_challenge(heim_digest_t context) break; case HEIM_DIGEST_TYPE_AUTO: context->type = HEIM_DIGEST_TYPE_RFC2831; - fallthrough; + HEIM_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/base32.c b/lib/roken/base32.c index ef74336d7..4ec86ae90 100644 --- a/lib/roken/base32.c +++ b/lib/roken/base32.c @@ -100,10 +100,10 @@ rk_base32_encode(const void *data, int size, char **str, enum rk_base32_flags fl p[6] = chars[(c & 0x0000000000000003e0ULL) >> 5]; p[7] = chars[(c & 0x00000000000000001fULL) >> 0]; switch (i - size) { - case 4: p[2] = p[3] = '='; fallthrough; - case 3: p[4] = '='; fallthrough; - case 2: p[5] = p[6] = '='; fallthrough; - case 1: p[7] = '='; fallthrough; + case 4: p[2] = p[3] = '='; HEIM_FALLTHROUGH; + case 3: p[4] = '='; HEIM_FALLTHROUGH; + case 2: p[5] = p[6] = '='; HEIM_FALLTHROUGH; + case 1: p[7] = '='; HEIM_FALLTHROUGH; default: break; } p += 8; diff --git a/lib/roken/dirent-test.c b/lib/roken/dirent-test.c index dc4518ad5..2c6b5055b 100644 --- a/lib/roken/dirent-test.c +++ b/lib/roken/dirent-test.c @@ -148,7 +148,7 @@ int teardown_test(void) strcmp(dirname + len + 1 - sizeof(TESTDIR)/sizeof(char), TESTDIR) == 0) { - fallthrough; + HEIM_FALLTHROUGH; } else { /* did we create the directory? */ @@ -162,7 +162,7 @@ int teardown_test(void) fprintf(stderr, "Can't change to test directory. Aborting cleanup.\n"); return -1; } else { - fallthrough; + HEIM_FALLTHROUGH; } } else { return -1; diff --git a/lib/roken/fnmatch.c b/lib/roken/fnmatch.c index 74f35283d..34da19f2c 100644 --- a/lib/roken/fnmatch.c +++ b/lib/roken/fnmatch.c @@ -129,7 +129,7 @@ rk_fnmatch(const char *pattern, const char *string, int flags) --pattern; } } - fallthrough; + HEIM_FALLTHROUGH; default: if (c != *string++) return (FNM_NOMATCH); diff --git a/lib/roken/getuserinfo.c b/lib/roken/getuserinfo.c index 7fd2ca9f1..09f4c7315 100644 --- a/lib/roken/getuserinfo.c +++ b/lib/roken/getuserinfo.c @@ -136,7 +136,7 @@ roken_get_homedir(char *home, size_t homesz) } return home; } - fallthrough; + HEIM_FALLTHROUGH; #else #ifdef HAVE_GETPWNAM_R size_t buflen = 2048; diff --git a/lib/roken/snprintf.c b/lib/roken/snprintf.c index 3da48962e..c8afedb26 100644 --- a/lib/roken/snprintf.c +++ b/lib/roken/snprintf.c @@ -515,7 +515,7 @@ xyzprintf (struct snprintf_state *state, const char *char_format, va_list ap) } case '\0' : --format; - fallthrough; + HEIM_FALLTHROUGH; case '%' : (*state->append_char)(state, c); ++len; diff --git a/lib/roken/strftime.c b/lib/roken/strftime.c index 9a951dd30..7be930755 100644 --- a/lib/roken/strftime.c +++ b/lib/roken/strftime.c @@ -377,7 +377,7 @@ strftime (char *buf, size_t maxsize, const char *format, break; case '\0' : --format; - fallthrough; + HEIM_FALLTHROUGH; case '%' : ret = snprintf (buf, maxsize - n, "%%"); diff --git a/lib/roken/strptime.c b/lib/roken/strptime.c index 86216d2d6..b9345c083 100644 --- a/lib/roken/strptime.c +++ b/lib/roken/strptime.c @@ -424,7 +424,7 @@ strptime (const char *buf, const char *format, struct tm *timeptr) abort (); case '\0' : --format; - fallthrough; + HEIM_FALLTHROUGH; case '%' : if (*buf == '%') ++buf; diff --git a/lib/wind/utf8.c b/lib/wind/utf8.c index 452b7b260..4559109f3 100644 --- a/lib/wind/utf8.c +++ b/lib/wind/utf8.c @@ -205,18 +205,18 @@ 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; + HEIM_FALLTHROUGH; case 3: out[2] = (ch | 0x80) & 0xbf; ch = ch >> 6; - fallthrough; + HEIM_FALLTHROUGH; case 2: out[1] = (ch | 0x80) & 0xbf; ch = ch >> 6; - fallthrough; + HEIM_FALLTHROUGH; case 1: out[0] = ch | first_char[len - 1]; - fallthrough; + HEIM_FALLTHROUGH; default: break; } @@ -486,14 +486,14 @@ 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; + HEIM_FALLTHROUGH; case 2: out[1] = (ch | 0x80) & 0xbf; ch = ch >> 6; - fallthrough; + HEIM_FALLTHROUGH; case 1: out[0] = ch | first_char[len - 1]; - fallthrough; + HEIM_FALLTHROUGH; default: break; }