From: Arran Cudbard-Bell Date: Sat, 16 Jan 2021 16:23:47 +0000 (+0000) Subject: Fix various pedantic warnings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2beeab723016c95f1c5e0d8ca6d66cfce669b807;p=thirdparty%2Ffreeradius-server.git Fix various pedantic warnings --- diff --git a/configure b/configure index f79d4aae1ec..559cd862d56 100755 --- 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 diff --git a/configure.ac b/configure.ac index fb1f4ed7e25..efae3ee1371 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/scripts/build/dlopen.c b/scripts/build/dlopen.c index 98ded1f278d..47320a11adf 100644 --- a/scripts/build/dlopen.c +++ b/scripts/build/dlopen.c @@ -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 diff --git a/scripts/build/version.c b/scripts/build/version.c index f3b48e5a861..89f4315ff30 100644 --- a/scripts/build/version.c +++ b/scripts/build/version.c @@ -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; diff --git a/src/lib/curl/base.c b/src/lib/curl/base.c index 92bb33783d7..91b7cf78380 100644 --- a/src/lib/curl/base.c +++ b/src/lib/curl/base.c @@ -26,9 +26,6 @@ #include #endif -#define CURL_NO_OLDIES 1 - -#include #include 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); diff --git a/src/lib/curl/io.c b/src/lib/curl/io.c index 10b2d8b7354..17bad21711e 100644 --- a/src/lib/curl/io.c +++ b/src/lib/curl/io.c @@ -27,11 +27,6 @@ #include #include -#define CURL_NO_OLDIES 1 - -#include -#include - /* * CURL headers do: * diff --git a/src/lib/io/atomic_queue.c b/src/lib/io/atomic_queue.c index fe47f458cde..af23678ff56 100644 --- a/src/lib/io/atomic_queue.c +++ b/src/lib/io/atomic_queue.c @@ -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. }; diff --git a/src/lib/server/tmpl_tokenize.c b/src/lib/server/tmpl_tokenize.c index ea1dbd901ab..9adf6c4666a 100644 --- a/src/lib/server/tmpl_tokenize.c +++ b/src/lib/server/tmpl_tokenize.c @@ -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 } diff --git a/src/lib/unlang/tmpl.c b/src/lib/unlang/tmpl.c index 716ec8432b5..36323aaa777 100644 --- a/src/lib/unlang/tmpl.c +++ b/src/lib/unlang/tmpl.c @@ -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; diff --git a/src/lib/util/dict.h b/src/lib/util/dict.h index e65f3573c44..f772ea01264 100644 --- a/src/lib/util/dict.h +++ b/src/lib/util/dict.h @@ -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 diff --git a/src/lib/util/dict_ext.h b/src/lib/util/dict_ext.h index 193af5fb983..64ae1b029b4 100644 --- a/src/lib/util/dict_ext.h +++ b/src/lib/util/dict_ext.h @@ -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 diff --git a/src/lib/util/sbuff.h b/src/lib/util/sbuff.h index ac022993cee..f70108cf5cf 100644 --- a/src/lib/util/sbuff.h +++ b/src/lib/util/sbuff.h @@ -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 diff --git a/src/lib/util/value.h b/src/lib/util/value.h index e8ba4c5a4a5..aeeb1ff0b47 100644 --- a/src/lib/util/value.h +++ b/src/lib/util/value.h @@ -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); diff --git a/src/modules/proto_dhcpv6/proto_dhcpv6.h b/src/modules/proto_dhcpv6/proto_dhcpv6.h index 2ea590caa61..d0b7151ed6f 100644 --- a/src/modules/proto_dhcpv6/proto_dhcpv6.h +++ b/src/modules/proto_dhcpv6/proto_dhcpv6.h @@ -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; diff --git a/src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c b/src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c index 6c903a37ba8..67bd988a2a6 100644 --- a/src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c +++ b/src/modules/rlm_eap/types/rlm_eap_mschapv2/rlm_eap_mschapv2.c @@ -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. diff --git a/src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c b/src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c index 2243a266671..2161cb06968 100644 --- a/src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c +++ b/src/modules/rlm_eap/types/rlm_eap_peap/rlm_eap_peap.c @@ -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; diff --git a/src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c b/src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c index 86220d4d5f3..86e972310e6 100644 --- a/src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c +++ b/src/modules/rlm_eap/types/rlm_eap_pwd/rlm_eap_pwd.c @@ -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) { diff --git a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c index 14d61166c96..d66095747ba 100644 --- a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c +++ b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c @@ -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[] = { diff --git a/src/modules/rlm_rest/rest.h b/src/modules/rlm_rest/rest.h index 218fe88fe30..827286e0632 100644 --- a/src/modules/rlm_rest/rest.h +++ b/src/modules/rlm_rest/rest.h @@ -30,10 +30,6 @@ RCSIDH(rest_h, "$Id$") #include #include -#define CURL_NO_OLDIES 1 - -#include - /* * The common JSON library (also tells us if we have json-c) */ diff --git a/src/modules/rlm_smtp/rlm_smtp.c b/src/modules/rlm_smtp/rlm_smtp.c index 7a9c89dc96c..ba7d9bb0b26 100644 --- a/src/modules/rlm_smtp/rlm_smtp.c +++ b/src/modules/rlm_smtp/rlm_smtp.c @@ -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; diff --git a/src/protocols/tacacs/tacacs.h b/src/protocols/tacacs/tacacs.h index 95305fd2d91..46b323918ac 100644 --- a/src/protocols/tacacs/tacacs.h +++ b/src/protocols/tacacs/tacacs.h @@ -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__) {