]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Address compilation warnings on FreeBSD 11.4
authorMichał Kępień <michal@isc.org>
Mon, 29 Jun 2020 10:03:01 +0000 (12:03 +0200)
committerMichał Kępień <michal@isc.org>
Mon, 29 Jun 2020 10:03:01 +0000 (12:03 +0200)
With Clang 10.0.0 on FreeBSD 11.4, compiling lib/dns/spnego.c triggers
the following warnings:

    spnego.c:361:11: error: converting the result of '<<' to a boolean always evaluates to true [-Werror,-Wtautological-constant-compare]
                    return (GSS_S_DEFECTIVE_TOKEN);
                            ^
    /usr/include/gssapi/gssapi.h:423:41: note: expanded from macro 'GSS_S_DEFECTIVE_TOKEN'
    #define GSS_S_DEFECTIVE_TOKEN      (9ul << GSS_C_ROUTINE_ERROR_OFFSET)
                                            ^
    spnego.c:366:11: error: converting the result of '<<' to a boolean always evaluates to true [-Werror,-Wtautological-constant-compare]
                    return (GSS_S_DEFECTIVE_TOKEN);
                            ^
    /usr/include/gssapi/gssapi.h:423:41: note: expanded from macro 'GSS_S_DEFECTIVE_TOKEN'
    #define GSS_S_DEFECTIVE_TOKEN      (9ul << GSS_C_ROUTINE_ERROR_OFFSET)
                                            ^
    spnego.c:371:12: error: converting the result of '<<' to a boolean always evaluates to true [-Werror,-Wtautological-constant-compare]
                            return (GSS_S_DEFECTIVE_TOKEN);
                                    ^
    /usr/include/gssapi/gssapi.h:423:41: note: expanded from macro 'GSS_S_DEFECTIVE_TOKEN'
    #define GSS_S_DEFECTIVE_TOKEN      (9ul << GSS_C_ROUTINE_ERROR_OFFSET)
                                            ^
    spnego.c:376:11: error: converting the result of '<<' to a boolean always evaluates to true [-Werror,-Wtautological-constant-compare]
                    return (GSS_S_DEFECTIVE_TOKEN);
                            ^
    /usr/include/gssapi/gssapi.h:423:41: note: expanded from macro 'GSS_S_DEFECTIVE_TOKEN'
    #define GSS_S_DEFECTIVE_TOKEN      (9ul << GSS_C_ROUTINE_ERROR_OFFSET)
                                            ^
    spnego.c:380:11: error: converting the result of '<<' to a boolean always evaluates to true [-Werror,-Wtautological-constant-compare]
                    return (GSS_S_DEFECTIVE_TOKEN);
                            ^
    /usr/include/gssapi/gssapi.h:423:41: note: expanded from macro 'GSS_S_DEFECTIVE_TOKEN'
    #define GSS_S_DEFECTIVE_TOKEN      (9ul << GSS_C_ROUTINE_ERROR_OFFSET)
                                            ^
    5 errors generated.

Address by replacing all instances of the GSS_S_DEFECTIVE_TOKEN constant
with a boolean value.  Invert the values returned by cmp_gss_type() so
that its only call site reads more naturally in the context of the
comment preceding it.

lib/dns/spnego.c

index c8efafe474f8327e2d94d6034a4e242bb58d87e4..4d824b509b1207830aadb37ab2b9c7bc0b6a110e 100644 (file)
@@ -352,35 +352,39 @@ gssapi_spnego_decapsulate(OM_uint32 *, gss_buffer_t, unsigned char **, size_t *,
 
 /* mod_auth_kerb.c */
 
+/*
+ * Check whether 'token' matches the SPNEGO OID.  If it does, return 'true';
+ * otherwise, return 'false'.
+ */
 static bool
 cmp_gss_type(gss_buffer_t token, gss_OID gssoid) {
        unsigned char *p;
        size_t len;
 
        if (token->length == 0U) {
-               return (GSS_S_DEFECTIVE_TOKEN);
+               return (false);
        }
 
        p = token->value;
        if (*p++ != 0x60) {
-               return (GSS_S_DEFECTIVE_TOKEN);
+               return (false);
        }
        len = *p++;
        if (len & 0x80) {
                if ((len & 0x7f) > 4U) {
-                       return (GSS_S_DEFECTIVE_TOKEN);
+                       return (false);
                }
                p += len & 0x7f;
        }
        if (*p++ != 0x06) {
-               return (GSS_S_DEFECTIVE_TOKEN);
+               return (false);
        }
 
        if (((OM_uint32)*p++) != gssoid->length) {
-               return (GSS_S_DEFECTIVE_TOKEN);
+               return (false);
        }
 
-       return (!isc_safe_memequal(p, gssoid->elements, gssoid->length));
+       return (isc_safe_memequal(p, gssoid->elements, gssoid->length));
 }
 
 /* accept_sec_context.c */
@@ -558,7 +562,7 @@ gss_accept_sec_context_spnego(OM_uint32 *minor_status,
         * PDU.  If not, dispatch to the GSSAPI library and get out.
         */
 
-       if (cmp_gss_type(input_token_buffer, GSS_SPNEGO_MECH)) {
+       if (!cmp_gss_type(input_token_buffer, GSS_SPNEGO_MECH)) {
                return (gss_accept_sec_context(
                        minor_status, context_handle, acceptor_cred_handle,
                        input_token_buffer, input_chan_bindings, src_name,