From d36bf51baf2338cc7f49601f679548960a8299c0 Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Tue, 23 Dec 2025 15:54:27 +0000 Subject: fix types for most curl_easy_setopt parameters according to https://curl.se/libcurl/c/curl_easy_setopt.html, parameters are either a long, a function pointer, an object pointer or a curl_off_t, depending on what the option expects; curl 8.16 checks and warns about these. --- plugins/check_curl.d/check_curl_helpers.c | 30 ++++++++++++++++-------------- plugins/check_curl.d/check_curl_helpers.h | 2 +- plugins/check_curl.d/config.h | 6 +++--- 3 files changed, 20 insertions(+), 18 deletions(-) (limited to 'plugins/check_curl.d') diff --git a/plugins/check_curl.d/check_curl_helpers.c b/plugins/check_curl.d/check_curl_helpers.c index e4e7bef6..7be781fc 100644 --- a/plugins/check_curl.d/check_curl_helpers.c +++ b/plugins/check_curl.d/check_curl_helpers.c @@ -19,7 +19,7 @@ bool add_sslctx_verify_fun = false; check_curl_configure_curl_wrapper check_curl_configure_curl(const check_curl_static_curl_config config, check_curl_working_state working_state, bool check_cert, - bool on_redirect_dependent, int follow_method, int max_depth) { + bool on_redirect_dependent, int follow_method, long max_depth) { check_curl_configure_curl_wrapper result = { .errorcode = OK, .curl_state = @@ -57,7 +57,7 @@ check_curl_configure_curl(const check_curl_static_curl_config config, result.curl_state.curl_easy_initialized = true; if (verbose >= 1) { - handle_curl_option_return_code(curl_easy_setopt(result.curl_state.curl, CURLOPT_VERBOSE, 1), + handle_curl_option_return_code(curl_easy_setopt(result.curl_state.curl, CURLOPT_VERBOSE, 1L), "CURLOPT_VERBOSE"); } @@ -214,10 +214,10 @@ check_curl_configure_curl(const check_curl_static_curl_config config, if (working_state.http_method) { if (!strcmp(working_state.http_method, "POST")) { handle_curl_option_return_code( - curl_easy_setopt(result.curl_state.curl, CURLOPT_POST, 1), "CURLOPT_POST"); + curl_easy_setopt(result.curl_state.curl, CURLOPT_POST, 1L), "CURLOPT_POST"); } else if (!strcmp(working_state.http_method, "PUT")) { handle_curl_option_return_code( - curl_easy_setopt(result.curl_state.curl, CURLOPT_UPLOAD, 1), "CURLOPT_UPLOAD"); + curl_easy_setopt(result.curl_state.curl, CURLOPT_UPLOAD, 1L), "CURLOPT_UPLOAD"); } else { handle_curl_option_return_code(curl_easy_setopt(result.curl_state.curl, CURLOPT_CUSTOMREQUEST, @@ -300,10 +300,10 @@ check_curl_configure_curl(const check_curl_static_curl_config config, /* per default if we have a CA verify both the peer and the * hostname in the certificate, can be switched off later */ handle_curl_option_return_code( - curl_easy_setopt(result.curl_state.curl, CURLOPT_SSL_VERIFYPEER, 1), + curl_easy_setopt(result.curl_state.curl, CURLOPT_SSL_VERIFYPEER, 1L), "CURLOPT_SSL_VERIFYPEER"); handle_curl_option_return_code( - curl_easy_setopt(result.curl_state.curl, CURLOPT_SSL_VERIFYHOST, 2), + curl_easy_setopt(result.curl_state.curl, CURLOPT_SSL_VERIFYHOST, 2L), "CURLOPT_SSL_VERIFYHOST"); } else { /* backward-compatible behaviour, be tolerant in checks @@ -311,10 +311,10 @@ check_curl_configure_curl(const check_curl_static_curl_config config, * to be less tolerant about ssl verfications */ handle_curl_option_return_code( - curl_easy_setopt(result.curl_state.curl, CURLOPT_SSL_VERIFYPEER, 0), + curl_easy_setopt(result.curl_state.curl, CURLOPT_SSL_VERIFYPEER, 0L), "CURLOPT_SSL_VERIFYPEER"); handle_curl_option_return_code( - curl_easy_setopt(result.curl_state.curl, CURLOPT_SSL_VERIFYHOST, 0), + curl_easy_setopt(result.curl_state.curl, CURLOPT_SSL_VERIFYHOST, 0L), "CURLOPT_SSL_VERIFYHOST"); } @@ -438,7 +438,7 @@ check_curl_configure_curl(const check_curl_static_curl_config config, if (on_redirect_dependent) { if (follow_method == FOLLOW_LIBCURL) { handle_curl_option_return_code( - curl_easy_setopt(result.curl_state.curl, CURLOPT_FOLLOWLOCATION, 1), + curl_easy_setopt(result.curl_state.curl, CURLOPT_FOLLOWLOCATION, 1L), "CURLOPT_FOLLOWLOCATION"); /* default -1 is infinite, not good, could lead to zombie plugins! @@ -474,7 +474,7 @@ check_curl_configure_curl(const check_curl_static_curl_config config, } /* no-body */ if (working_state.no_body) { - handle_curl_option_return_code(curl_easy_setopt(result.curl_state.curl, CURLOPT_NOBODY, 1), + handle_curl_option_return_code(curl_easy_setopt(result.curl_state.curl, CURLOPT_NOBODY, 1L), "CURLOPT_NOBODY"); } @@ -796,15 +796,17 @@ mp_subcheck check_document_dates(const curlhelp_write_curlbuf *header_buf, const ((float)last_modified) / (60 * 60 * 24)); sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_CRITICAL); } else { - xasprintf(&sc_document_dates.output, _("Last modified %ld:%02ld:%02ld ago"), - last_modified / (60 * 60), (last_modified / 60) % 60, last_modified % 60); + xasprintf(&sc_document_dates.output, _("Last modified %lld:%02d:%02d ago"), + (long long)last_modified / (60 * 60), (int)(last_modified / 60) % 60, + (int)last_modified % 60); sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_CRITICAL); } } else { // TODO is this the OK case? time_t last_modified = (srv_data - doc_data); - xasprintf(&sc_document_dates.output, _("Last modified %ld:%02ld:%02ld ago"), - last_modified / (60 * 60), (last_modified / 60) % 60, last_modified % 60); + xasprintf(&sc_document_dates.output, _("Last modified %lld:%02d:%02d ago"), + (long long)last_modified / (60 * 60), (int)(last_modified / 60) % 60, + (int)last_modified % 60); sc_document_dates = mp_set_subcheck_state(sc_document_dates, STATE_OK); } } diff --git a/plugins/check_curl.d/check_curl_helpers.h b/plugins/check_curl.d/check_curl_helpers.h index e7b80f7e..e77b763b 100644 --- a/plugins/check_curl.d/check_curl_helpers.h +++ b/plugins/check_curl.d/check_curl_helpers.h @@ -80,7 +80,7 @@ check_curl_configure_curl_wrapper check_curl_configure_curl(check_curl_static_cu check_curl_working_state working_state, bool check_cert, bool on_redirect_dependent, - int follow_method, int max_depth); + int follow_method, long max_depth); void handle_curl_option_return_code(CURLcode res, const char *option); diff --git a/plugins/check_curl.d/config.h b/plugins/check_curl.d/config.h index f51b2ee9..61067d46 100644 --- a/plugins/check_curl.d/config.h +++ b/plugins/check_curl.d/config.h @@ -57,10 +57,10 @@ typedef struct { bool haproxy_protocol; long socket_timeout; sa_family_t sin_family; - int curl_http_version; + long curl_http_version; char **http_opt_headers; size_t http_opt_headers_count; - int ssl_version; + long ssl_version; char *client_cert; char *client_privkey; char *ca_cert; @@ -76,7 +76,7 @@ typedef struct { check_curl_working_state initial_config; check_curl_static_curl_config curl_config; - int max_depth; + long max_depth; int followmethod; int followsticky; -- cgit v1.2.3-74-g34f1