]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix various pedantic warnings
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 16 Jan 2021 16:23:47 +0000 (16:23 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 16 Jan 2021 16:23:53 +0000 (16:23 +0000)
21 files changed:
configure
configure.ac
scripts/build/dlopen.c
scripts/build/version.c
src/lib/curl/base.c
src/lib/curl/io.c
src/lib/io/atomic_queue.c
src/lib/server/tmpl_tokenize.c
src/lib/unlang/tmpl.c
src/lib/util/dict.h
src/lib/util/dict_ext.h
src/lib/util/sbuff.h
src/lib/util/value.h
src/modules/proto_dhcpv6/proto_dhcpv6.h
src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c
src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c
src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c
src/modules/rlm_redis_ippool/rlm_redis_ippool.c
src/modules/rlm_rest/rest.h
src/modules/rlm_smtp/rlm_smtp.c
src/protocols/tacacs/tacacs.h

index f79d4aae1ec8b1a87f73dca6b2b70e1f79af5a74..559cd862d5633afa19c9a8bc20f2281d65ff202d 100755 (executable)
--- a/configure
+++ b/configure
@@ -13146,23 +13146,24 @@ $as_echo "$ax_cv_cc_weverything_flag" >&6; }
        -W \
        -Weverything \
        -Wformat=2 \
+       -Wno-date-time \
        -Wno-disabled-macro-expansion \
+       -Wno-format-pedantic \
        -Wno-missing-field-initializers \
-       -Wno-date-time \
-       -Wno-padded \
-       -Wno-gnu-zero-variadic-macro-arguments \
-       -Wno-shorten-64-to-32 \
-       -Wno-sign-conversion \
-       -Wno-conversion \
-       -Wno-switch-enum \
-       -Wno-gnu-statement-expression \
-       -Wno-extended-offsetof \
        -Wno-cast-align \
-       -Wno-documentation-unknown-command \
+       -Wno-conversion \
        -Wno-covered-switch-default \
+       -Wno-documentation-unknown-command \
+       -Wno-extended-offsetof \
+       -Wno-gnu-statement-expression \
+       -Wno-gnu-zero-variadic-macro-arguments \
        -Wno-packed \
+       -Wno-padded \
        -Wno-reserved-id-macro \
-       -Wno-format-pedantic \
+       -Wno-shorten-64-to-32 \
+       -Wno-sign-conversion \
+       -Wno-switch-enum \
+       -wno-gnu-empty-initializer \
         $verify_ptr"
   else
     if test "x$GCC" = "xyes"; then
index fb1f4ed7e25a995b40017f4c6a25f1947a4b0849..efae3ee13717592c20544821efe4f83482446d68 100644 (file)
@@ -1712,23 +1712,24 @@ if test "x$developer" = "xyes"; then
        -W \
        -Weverything \
        -Wformat=2 \
+       -Wno-date-time \
        -Wno-disabled-macro-expansion \
+       -Wno-format-pedantic \
        -Wno-missing-field-initializers \
-       -Wno-date-time \
-       -Wno-padded \
-       -Wno-gnu-zero-variadic-macro-arguments \
-       -Wno-shorten-64-to-32 \
-       -Wno-sign-conversion \
-       -Wno-conversion \
-       -Wno-switch-enum \
-       -Wno-gnu-statement-expression \
-       -Wno-extended-offsetof \
        -Wno-cast-align \
-       -Wno-documentation-unknown-command \
+       -Wno-conversion \
        -Wno-covered-switch-default \
+       -Wno-documentation-unknown-command \
+       -Wno-extended-offsetof \
+       -Wno-gnu-statement-expression \
+       -Wno-gnu-zero-variadic-macro-arguments \
        -Wno-packed \
+       -Wno-padded \
        -Wno-reserved-id-macro \
-       -Wno-format-pedantic \
+       -Wno-shorten-64-to-32 \
+       -Wno-sign-conversion \
+       -Wno-switch-enum \
+       -wno-gnu-empty-initializer \
         $verify_ptr"
   else
     if test "x$GCC" = "xyes"; then
index 98ded1f278d01288d0ad7f1a7daf39ada6c55957..47320a11adf35bc819bbf8a3ad72a4ad6c7899af 100644 (file)
@@ -561,7 +561,7 @@ static char *make_dlerror(__attribute__((unused)) char const *nm, __attribute__(
 typedef struct ad_define_s {
        struct ad_define_s *next;
        size_t              len;
-       char                name[0];
+       char                name[];
 } ad_define_t;
 
 static ad_define_t *ad_define_head = NULL;
@@ -776,7 +776,7 @@ static char *make_ad_search_libs(__attribute__((unused)) char const *nm, unsigne
        char *p, *q, *r;
        char const *name;
        void *symbol = NULL;
-       void *handle;
+       void *handle = NULL;
 
        /*
         *      Get the symbol name
index f3b48e5a861f84abeb5f433192c75d14367439eb..89f4315ff30ca60da5df6e91c24551d0fac304ea 100644 (file)
@@ -81,7 +81,7 @@ static int make_version_cmp(bool *err,
 
        while ((a < a_end) && (b < b_end)) {
                unsigned long   a_num, b_num;
-               size_t          a_len, b_len;
+               size_t          a_len = 0, b_len;
                int             ret;
                bool            a_str = false;
 
index 92bb33783d78132d28a09838b64b9fa1283cd2c3..91b7cf78380fe4d2992265a31006a0885f6f023f 100644 (file)
@@ -26,9 +26,6 @@
 #include <freeradius-devel/tls/base.h>
 #endif
 
-#define CURL_NO_OLDIES 1
-
-#include <curl/curl.h>
 #include <talloc.h>
 
 static uint32_t instance_count = 0;
@@ -39,10 +36,10 @@ static fr_dict_autoload_t curl_dict[] = {
        { NULL }
 };
 
-fr_table_num_sorted_t const fr_curl_sslcode_table[] = {
-       {L("allow"),            CURLUSESSL_TRY          },
-       {L("demand"),           CURLUSESSL_ALL          },
-       {L("never"),    CURLUSESSL_NONE         },
+static fr_table_num_sorted_t const fr_curl_sslcode_table[] = {
+       {L("allow"),     CURLUSESSL_TRY          },
+       {L("demand"),    CURLUSESSL_ALL          },
+       {L("never"),     CURLUSESSL_NONE         },
 };
 static size_t fr_curl_sslcode_table_len = NUM_ELEMENTS(fr_curl_sslcode_table);
 
index 10b2d8b7354919f0df81136d1b3b8b36315a615c..17bad21711e257b5b2e39520c1196878ced5ed60 100644 (file)
 #include <freeradius-devel/unlang/base.h>
 #include <freeradius-devel/util/syserror.h>
 
-#define CURL_NO_OLDIES 1
-
-#include <curl/curl.h>
-#include <talloc.h>
-
 /*
  *  CURL headers do:
  *
index fe47f458cde95614e5ca6326f97e0ff994768fc9..af23678ff5625c968543ac03afca1a779bcb5d44 100644 (file)
@@ -59,7 +59,7 @@ struct fr_atomic_queue_s {
 
        void                                            *chunk;         //!< To pass to free. The non-aligned address.
 
-       alignas(CACHE_LINE_SIZE) fr_atomic_queue_entry_t entry[0];      //!< The entry array, also aligned
+       alignas(CACHE_LINE_SIZE) fr_atomic_queue_entry_t entry[];       //!< The entry array, also aligned
                                                                        ///< to ensure it's not in the same cache
                                                                        ///< line as tail and size.
 };
index ea1dbd901abb8de92bd4667f30745e827050134d..9adf6c4666a33faf10f5e017aa3435591b09ee94 100644 (file)
@@ -68,7 +68,7 @@ size_t tmpl_type_table_len = NUM_ELEMENTS(tmpl_type_table);
 
 /** Attr ref types
  */
-fr_table_num_ordered_t const attr_table[] = {
+static r_table_num_ordered_t const attr_table[] = {
        { L("normal"),          TMPL_ATTR_TYPE_NORMAL           },
        { L("unknown"),         TMPL_ATTR_TYPE_UNKNOWN          },
        { L("unresolved"),      TMPL_ATTR_TYPE_UNRESOLVED       }
index 716ec8432b5f08ae8276e4e40f2768674841f234..36323aaa777cfc19261fa90f4edf48d66bfae8aa 100644 (file)
@@ -247,7 +247,11 @@ static void unlang_tmpl_exec_read(UNUSED fr_event_list_t *el, UNUSED int fd, UNU
        state->ptr = p;
 }
 
-static void unlang_tmpl_exec_timeout(UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
+static void unlang_tmpl_exec_timeout(
+#ifndef __linux__
+                                    UNUSED
+#endif
+                                    fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
 {
        request_t                       *request = uctx;
        unlang_stack_t                  *stack = request->stack;
index e65f3573c44ce4383d3032f4f4804beb6179d80f..f772ea01264fd102c3377923f644a30beb01d107 100644 (file)
@@ -170,7 +170,7 @@ typedef struct {
 
        uint8_t                 ext[FR_DICT_ENUM_EXT_MAX];      //!< Extensions to the dictionary attribute.
 
-       fr_dict_attr_t const    *child_struct[0];               //!< for key fields
+       fr_dict_attr_t const    *child_struct[];                //!< for key fields
 } fr_dict_enum_t CC_HINT(aligned(FR_EXT_ALIGNMENT));
 
 /** Private enterprise
index 193af5fb9832193197bba58eb67a231d36bb616c..64ae1b029b478d6507d0ef66a85fdfd79db7b194 100644 (file)
@@ -71,7 +71,13 @@ typedef struct {
  *
  */
 typedef struct {
-       fr_dict_attr_t const    *da_stack[0];                   //!< Stack of dictionary attributes
+       bool                    unused;                         //!< Zero length arrays are apparently GNU extensions
+                                                               ///< and we're not allowed to have structs with a
+                                                               ///< single variable array as its member.
+                                                               ///< We'll likely want to store something else here
+                                                               ///< at some point, so we just have a dummy field to
+                                                               ///< avoid changing all the code.
+       fr_dict_attr_t const    *da_stack[];                    //!< Stack of dictionary attributes
 } fr_dict_attr_ext_da_stack_t;
 
 /** Attribute extension - Holds enumeration values
index ac022993ceea57579b08fedbd8f9cb40a6b0736f..f70108cf5cf2d6e719d3707a50b920f1de05c4a2 100644 (file)
@@ -1308,24 +1308,24 @@ do { \
        return (size_t)slen; \
 
 static inline size_t fr_sbuff_out_abstrncpy(TALLOC_CTX *ctx, char **out, fr_sbuff_t *in, size_t len)
-SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_bstrncpy, in, len);
+SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_bstrncpy, in, len)
 
 static inline size_t fr_sbuff_out_abstrncpy_exact(TALLOC_CTX *ctx, char **out, fr_sbuff_t *in, size_t len)
-SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_bstrncpy_exact, in, len);
+SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_bstrncpy_exact, in, len)
 
 static inline size_t fr_sbuff_out_abstrncpy_allowed(TALLOC_CTX *ctx, char **out, fr_sbuff_t *in, size_t len,
                                                    bool const allowed[static UINT8_MAX + 1])
-SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_bstrncpy_allowed, in, len, allowed);
+SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_bstrncpy_allowed, in, len, allowed)
 
 static inline size_t fr_sbuff_out_abstrncpy_until(TALLOC_CTX *ctx, char **out, fr_sbuff_t *in, size_t len,
                                                  fr_sbuff_term_t const *tt,
                                                  fr_sbuff_unescape_rules_t const *u_rules)
-SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_bstrncpy_until, in, len, tt, u_rules);
+SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_bstrncpy_until, in, len, tt, u_rules)
 
 static inline size_t fr_sbuff_out_aunescape_until(TALLOC_CTX *ctx, char **out, fr_sbuff_t *in, size_t len,
                                                  fr_sbuff_term_t const *tt,
                                                  fr_sbuff_unescape_rules_t const *u_rules)
-SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_unescape_until, in, len, tt, u_rules);
+SBUFF_OUT_TALLOC_FUNC_DEF(fr_sbuff_out_unescape_until, in, len, tt, u_rules)
 /** @} */
 
 /** @name Look for a token in a particular format, parse it, and write it to the output pointer
index e8ba4c5a4a5f1714fb13bf361ac119c8e7337985..aeeb1ff0b47136c159abff3881d18744c3810160 100644 (file)
@@ -575,10 +575,10 @@ size_t            fr_value_str_unescape(fr_sbuff_t *out, fr_sbuff_t *in, size_t inlen, cha
 size_t         fr_value_substr_unescape(fr_sbuff_t *out, fr_sbuff_t *in, size_t inlen, char quote);
 
 static inline size_t fr_value_str_aunescape(TALLOC_CTX *ctx, char **out, fr_sbuff_t *in, size_t inlen, char quote)
-SBUFF_OUT_TALLOC_FUNC_DEF(fr_value_str_unescape, in, inlen, quote);
+SBUFF_OUT_TALLOC_FUNC_DEF(fr_value_str_unescape, in, inlen, quote)
 
 static inline size_t fr_value_substr_aunescape(TALLOC_CTX *ctx, char **out, fr_sbuff_t *in, size_t inlen, char quote)
-SBUFF_OUT_TALLOC_FUNC_DEF(fr_value_substr_unescape, in, inlen, quote);
+SBUFF_OUT_TALLOC_FUNC_DEF(fr_value_substr_unescape, in, inlen, quote)
 
 int            fr_value_box_hton(fr_value_box_t *dst, fr_value_box_t const *src);
 
index 2ea590caa6155dba5ceb436bbdcfa0f19423d308..d0b7151ed6f1189ce5f64ab54edbc10d0cf1b525 100644 (file)
@@ -52,5 +52,5 @@ typedef struct {
 typedef struct {
        uint32_t                        header;
        size_t                          client_id_len;
-       uint8_t                         client_id[0];
+       uint8_t                         client_id[];
 } proto_dhcpv6_track_t;
index 6c903a37ba8a1213bf0341fe7a562a3aa6064889..67bd988a2a60e322fba9ae093d459ed564302d05 100644 (file)
@@ -314,7 +314,7 @@ static int CC_HINT(nonnull) mschap_postproxy(eap_session_t *eap_session, UNUSED
         *      Done doing EAP proxy stuff.
         */
        request->options &= ~RAD_REQUEST_OPTION_PROXY_EAP;
-       if (!fr_cond_assert(eap_session->inst)) return 0;
+       if (!fr_cond_assert(eap_session->inst)) RETURN_MODULE_FAIL;
        eap_mschapv2_compose(eap_session->inst, request, eap_session, response);
        data->code = FR_EAP_MSCHAPV2_SUCCESS;
 
@@ -459,7 +459,7 @@ static unlang_action_t CC_HINT(nonnull) mod_process(rlm_rcode_t *p_result, modul
        uint8_t                         *p;
        size_t                          length;
 
-       if (!fr_cond_assert(eap_session->inst)) return 0;
+       if (!fr_cond_assert(eap_session->inst)) RETURN_MODULE_FAIL;
 
        /*
         *      Sanity check the response.
index 2243a26667135a7c1923c4e90ed4e648ab7ca7ae..2161cb069683d618d1c4952f0e65d6eb26ba36c6 100644 (file)
@@ -227,7 +227,7 @@ static unlang_action_t CC_HINT(nonnull) mod_process(rlm_rcode_t *p_result, modul
                 */
                if (eap_tls_success(request, eap_session,
                                    keying_prf_label, sizeof(keying_prf_label) - 1,
-                                   NULL, 0) < 0) return 0;
+                                   NULL, 0) < 0) RETURN_MODULE_RCODE(rcode);
        }
                break;
 
index 86220d4d5f3e77efa28b0c1df1232346e18ce816..86e972310e6cc116fe11903df307aa9b531fee62 100644 (file)
@@ -172,7 +172,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc
        uint8_t         exch, *in, *ptr, msk[MSK_EMSK_LEN], emsk[MSK_EMSK_LEN];
        uint8_t         peer_confirm[SHA256_DIGEST_LENGTH];
 
-       if (((eap_round = eap_session->this_round) == NULL) || !inst) return 0;
+       if (((eap_round = eap_session->this_round) == NULL) || !inst) RETURN_MODULE_FAIL;
 
        session = talloc_get_type_abort(eap_session->opaque, pwd_session_t);
        response = eap_session->this_round->response;
@@ -233,8 +233,8 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc
         */
        if (EAP_PWD_GET_MORE_BIT(hdr)) {
                if (!session->in) {
-                       RDEBUG2("Unexpected fragment.");
-                       return 0;
+                       RDEBUG2("Unexpected fragment");
+                       RETURN_MODULE_INVALID;
                }
 
                if ((session->in_pos + in_len) > session->in_len) {
index 14d61166c9627c663798ab1d8dcbeea1285a7e50..d66095747ba2b7443fb84efacc7f7ab1bd7a197c 100644 (file)
@@ -161,11 +161,11 @@ fr_dict_attr_autoload_t rlm_redis_ippool_dict_attr[] = {
        { NULL }
 };
 
-fr_value_box_t const   *enum_acct_status_type_start;
-fr_value_box_t const   *enum_acct_status_type_interim_update;
-fr_value_box_t const   *enum_acct_status_type_stop;
-fr_value_box_t const   *enum_acct_status_type_on;
-fr_value_box_t const   *enum_acct_status_type_off;
+static fr_value_box_t const    *enum_acct_status_type_start;
+static fr_value_box_t const    *enum_acct_status_type_interim_update;
+static fr_value_box_t const    *enum_acct_status_type_stop;
+static fr_value_box_t const    *enum_acct_status_type_on;
+static fr_value_box_t const    *enum_acct_status_type_off;
 
 extern fr_dict_enum_autoload_t rlm_redis_ippool_dict_enum[];
 fr_dict_enum_autoload_t rlm_redis_ippool_dict_enum[] = {
index 218fe88fe30badf24a58a91215d89aa3d0a7e275..827286e0632c6cdbd513745b6ca3aaa8c001e5f9 100644 (file)
@@ -30,10 +30,6 @@ RCSIDH(rest_h, "$Id$")
 #include <freeradius-devel/server/pairmove.h>
 #include <freeradius-devel/server/pool.h>
 
-#define CURL_NO_OLDIES 1
-
-#include <curl/curl.h>
-
 /*
  *     The common JSON library (also tells us if we have json-c)
  */
index 7a9c89dc96ca6b8bdf765b5b2bfae7e30bf4fc75..ba7d9bb0b26161be7eec18a7a893260d13a33fde 100644 (file)
@@ -102,8 +102,8 @@ typedef struct {
 /*
  *     Used to ensure that only strings are being set to the tmpl_t ** output
  */
-static int cf_table_parse_tmpl(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent,
-                         CONF_ITEM *ci, CONF_PARSER const *rule)
+static int cf_table_parse_tmpl(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
+                              CONF_ITEM *ci, CONF_PARSER const *rule)
 {
        int                     ret = 0;
        ssize_t                 slen;
@@ -501,15 +501,15 @@ static int recipients_source(rlm_smtp_thread_t *t, fr_mail_ctx *uctx, rlm_smtp_t
 /*
  *     Generates a curl_slist of header elements header elements
  */
-static int header_source(rlm_smtp_thread_t *t, fr_mail_ctx *uctx, UNUSED rlm_smtp_t const *inst)
+static int header_source(rlm_smtp_thread_t *t, fr_mail_ctx *uctx, rlm_smtp_t const *inst)
 {
        fr_sbuff_t                      time_out;
        char const                      *to = "TO: ";
        char const                      *cc = "CC: ";
-       request_t                               *request = uctx->request;
+       request_t                       *request = uctx->request;
        fr_sbuff_t                      conf_buffer;
        fr_sbuff_uctx_talloc_t          conf_ctx;
-       map_t                   *conf_map;
+       map_t                           *conf_map;
 
        char                            *expanded_rhs;
 
index 95305fd2d91cd0af91dc37f3cc3a0e6260270952..46b323918acf4527cf8f5f7d6cc778b89789fce9 100644 (file)
@@ -136,7 +136,7 @@ typedef struct CC_HINT(__packed__) {
        uint8_t                         port_len;
        uint8_t                         rem_addr_len;
        uint8_t                         data_len;
-       uint8_t                         body[0];
+       uint8_t                         body[];
 } fr_tacacs_packet_authen_start_hdr_t;
 
 typedef enum {
@@ -160,7 +160,7 @@ typedef struct CC_HINT(__packed__) {
        fr_tacacs_authen_reply_flags_t  flags:8;
        uint16_t                        server_msg_len;
        uint16_t                        data_len;
-       uint8_t                         body[0];
+       uint8_t                         body[];
 } fr_tacacs_packet_authen_reply_hdr_t;
 
 typedef enum {
@@ -172,7 +172,7 @@ typedef struct CC_HINT(__packed__) {
        uint16_t                        user_msg_len;
        uint16_t                        data_len;
        fr_tacacs_authen_cont_flags_t   flags:8;
-       uint8_t                         body[0];
+       uint8_t                         body[];
 } fr_tacacs_packet_authen_cont_hdr_t;
 
 typedef enum {
@@ -198,7 +198,7 @@ typedef struct CC_HINT(__packed__) {
        uint8_t                         port_len;
        uint8_t                         rem_addr_len;
        uint8_t                         arg_cnt;
-       uint8_t                         body[0];
+       uint8_t                         body[];
 } fr_tacacs_packet_author_req_hdr_t;
 
 typedef enum {
@@ -214,7 +214,7 @@ typedef struct CC_HINT(__packed__) {
        uint8_t                         arg_cnt;
        uint16_t                        server_msg_len;
        uint16_t                        data_len;
-       uint8_t                         body[0];
+       uint8_t                         body[];
 } fr_tacacs_packet_author_res_hdr_t;
 
 typedef enum {
@@ -233,7 +233,7 @@ typedef struct CC_HINT(__packed__) {
        uint8_t                         port_len;
        uint8_t                         rem_addr_len;
        uint8_t                         arg_cnt;
-       uint8_t                         body[0];
+       uint8_t                         body[];
 } fr_tacacs_packet_acct_req_hdr_t;
 
 typedef enum {
@@ -255,7 +255,7 @@ typedef struct CC_HINT(__packed__) {
        uint16_t                        server_msg_len;
        uint16_t                        data_len;
        fr_tacacs_acct_reply_status_t   status:8;
-       uint8_t                         body[0];
+       uint8_t                         body[];
 } fr_tacacs_packet_acct_reply_hdr_t;
 
 typedef struct CC_HINT(__packed__) {