diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-31 02:10:57 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2024-10-31 02:10:57 (GMT) |
commit | fde8e9c77b094ccec536d05c634d9d8f1f0e3abc (patch) | |
tree | 01e7f9847ded1fad9004dac857108371488c7910 | |
parent | 7334812a929768aa310557ae823b91df79b32f51 (diff) | |
download | monitoring-plugins-fde8e9c77b094ccec536d05c634d9d8f1f0e3abc.tar.gz |
check_curl: Linter fixes
-rw-r--r-- | plugins/check_curl.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 06fc6d6..1d27da2 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -225,41 +225,41 @@ static bool automatic_decompression = false; | |||
225 | static char *cookie_jar_file = NULL; | 225 | static char *cookie_jar_file = NULL; |
226 | static bool haproxy_protocol = false; | 226 | static bool haproxy_protocol = false; |
227 | 227 | ||
228 | static bool process_arguments(int, char **); | 228 | static bool process_arguments(int /*argc*/, char ** /*argv*/); |
229 | static void handle_curl_option_return_code(CURLcode res, const char *option); | 229 | static void handle_curl_option_return_code(CURLcode res, const char *option); |
230 | static int check_http(void); | 230 | static int check_http(void); |
231 | static void redir(curlhelp_write_curlbuf *); | 231 | static void redir(curlhelp_write_curlbuf * /*header_buf*/); |
232 | static char *perfd_time(double microsec); | 232 | static char *perfd_time(double elapsed_time); |
233 | static char *perfd_time_connect(double microsec); | 233 | static char *perfd_time_connect(double elapsed_time_connect); |
234 | static char *perfd_time_ssl(double microsec); | 234 | static char *perfd_time_ssl(double elapsed_time_ssl); |
235 | static char *perfd_time_firstbyte(double microsec); | 235 | static char *perfd_time_firstbyte(double elapsed_time_firstbyte); |
236 | static char *perfd_time_headers(double microsec); | 236 | static char *perfd_time_headers(double elapsed_time_headers); |
237 | static char *perfd_time_transfer(double microsec); | 237 | static char *perfd_time_transfer(double elapsed_time_transfer); |
238 | static char *perfd_size(int page_len); | 238 | static char *perfd_size(int page_len); |
239 | static void print_help(void); | 239 | static void print_help(void); |
240 | void print_usage(void); | 240 | void print_usage(void); |
241 | static void print_curl_version(void); | 241 | static void print_curl_version(void); |
242 | static int curlhelp_initwritebuffer(curlhelp_write_curlbuf *); | 242 | static int curlhelp_initwritebuffer(curlhelp_write_curlbuf * /*buf*/); |
243 | static size_t curlhelp_buffer_write_callback(void *, size_t, size_t, void *); | 243 | static size_t curlhelp_buffer_write_callback(void * /*buffer*/, size_t /*size*/, size_t /*nmemb*/, void * /*stream*/); |
244 | static void curlhelp_freewritebuffer(curlhelp_write_curlbuf *); | 244 | static void curlhelp_freewritebuffer(curlhelp_write_curlbuf * /*buf*/); |
245 | static int curlhelp_initreadbuffer(curlhelp_read_curlbuf *, const char *, size_t); | 245 | static int curlhelp_initreadbuffer(curlhelp_read_curlbuf * /*buf*/, const char * /*data*/, size_t /*datalen*/); |
246 | static size_t curlhelp_buffer_read_callback(void *, size_t, size_t, void *); | 246 | static size_t curlhelp_buffer_read_callback(void * /*buffer*/, size_t /*size*/, size_t /*nmemb*/, void * /*stream*/); |
247 | static void curlhelp_freereadbuffer(curlhelp_read_curlbuf *); | 247 | static void curlhelp_freereadbuffer(curlhelp_read_curlbuf * /*buf*/); |
248 | static curlhelp_ssl_library curlhelp_get_ssl_library(); | 248 | static curlhelp_ssl_library curlhelp_get_ssl_library(void); |
249 | static const char *curlhelp_get_ssl_library_string(curlhelp_ssl_library); | 249 | static const char *curlhelp_get_ssl_library_string(curlhelp_ssl_library /*ssl_library*/); |
250 | int net_noopenssl_check_certificate(cert_ptr_union *, int, int); | 250 | int net_noopenssl_check_certificate(cert_ptr_union *, int, int); |
251 | 251 | ||
252 | static int curlhelp_parse_statusline(const char *, curlhelp_statusline *); | 252 | static int curlhelp_parse_statusline(const char * /*buf*/, curlhelp_statusline * /*status_line*/); |
253 | static void curlhelp_free_statusline(curlhelp_statusline *); | 253 | static void curlhelp_free_statusline(curlhelp_statusline * /*status_line*/); |
254 | static char *get_header_value(const struct phr_header *headers, const size_t nof_headers, const char *header); | 254 | static char *get_header_value(const struct phr_header *headers, size_t nof_headers, const char *header); |
255 | static int check_document_dates(const curlhelp_write_curlbuf *, char (*msg)[DEFAULT_BUFFER_SIZE]); | 255 | static int check_document_dates(const curlhelp_write_curlbuf * /*header_buf*/, char (*msg)[DEFAULT_BUFFER_SIZE]); |
256 | static int get_content_length(const curlhelp_write_curlbuf *header_buf, const curlhelp_write_curlbuf *body_buf); | 256 | static int get_content_length(const curlhelp_write_curlbuf *header_buf, const curlhelp_write_curlbuf *body_buf); |
257 | 257 | ||
258 | #if defined(HAVE_SSL) && defined(USE_OPENSSL) | 258 | #if defined(HAVE_SSL) && defined(USE_OPENSSL) |
259 | int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int days_till_exp_crit); | 259 | int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int days_till_exp_crit); |
260 | #endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */ | 260 | #endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */ |
261 | 261 | ||
262 | static void test_file(char *); | 262 | static void test_file(char * /*path*/); |
263 | 263 | ||
264 | int main(int argc, char **argv) { | 264 | int main(int argc, char **argv) { |
265 | int result = STATE_UNKNOWN; | 265 | int result = STATE_UNKNOWN; |
@@ -301,7 +301,8 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) { | |||
301 | # endif | 301 | # endif |
302 | if (verbose >= 2) { | 302 | if (verbose >= 2) { |
303 | puts("* SSL verify callback with certificate:"); | 303 | puts("* SSL verify callback with certificate:"); |
304 | X509_NAME *subject, *issuer; | 304 | X509_NAME *subject; |
305 | X509_NAME *issuer; | ||
305 | printf("* issuer:\n"); | 306 | printf("* issuer:\n"); |
306 | issuer = X509_get_issuer_name(cert); | 307 | issuer = X509_get_issuer_name(cert); |
307 | X509_NAME_print_ex_fp(stdout, issuer, 5, XN_FLAG_MULTILINE); | 308 | X509_NAME_print_ex_fp(stdout, issuer, 5, XN_FLAG_MULTILINE); |
@@ -356,7 +357,8 @@ static char *string_statuscode(int major, int minor) { | |||
356 | 357 | ||
357 | /* Checks if the server 'reply' is one of the expected 'statuscodes' */ | 358 | /* Checks if the server 'reply' is one of the expected 'statuscodes' */ |
358 | static int expected_statuscode(const char *reply, const char *statuscodes) { | 359 | static int expected_statuscode(const char *reply, const char *statuscodes) { |
359 | char *expected, *code; | 360 | char *expected; |
361 | char *code; | ||
360 | int result = 0; | 362 | int result = 0; |
361 | 363 | ||
362 | if ((expected = strdup(statuscodes)) == NULL) | 364 | if ((expected = strdup(statuscodes)) == NULL) |
@@ -523,7 +525,7 @@ int check_http(void) { | |||
523 | // use the host_name later on to make SNI happy | 525 | // use the host_name later on to make SNI happy |
524 | if (use_ssl && host_name != NULL) { | 526 | if (use_ssl && host_name != NULL) { |
525 | if ((res = lookup_host(server_address, addrstr, DEFAULT_BUFFER_SIZE / 2)) != 0) { | 527 | if ((res = lookup_host(server_address, addrstr, DEFAULT_BUFFER_SIZE / 2)) != 0) { |
526 | snprintf(msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"), server_address, res, | 528 | snprintf(msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %d"), server_address, res, |
527 | gai_strerror(res)); | 529 | gai_strerror(res)); |
528 | die(STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); | 530 | die(STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); |
529 | } | 531 | } |
@@ -2183,8 +2185,7 @@ const char *strrstr2(const char *haystack, const char *needle) { | |||
2183 | if (pos == NULL) { | 2185 | if (pos == NULL) { |
2184 | if (counter == 0) | 2186 | if (counter == 0) |
2185 | return NULL; | 2187 | return NULL; |
2186 | else | 2188 | return prev_pos; |
2187 | return prev_pos; | ||
2188 | } | 2189 | } |
2189 | counter++; | 2190 | counter++; |
2190 | prev_pos = pos; | 2191 | prev_pos = pos; |
@@ -2438,7 +2439,7 @@ int get_content_length(const curlhelp_write_curlbuf *header_buf, const curlhelp_ | |||
2438 | } | 2439 | } |
2439 | 2440 | ||
2440 | /* TODO: is there a better way in libcurl to check for the SSL library? */ | 2441 | /* TODO: is there a better way in libcurl to check for the SSL library? */ |
2441 | curlhelp_ssl_library curlhelp_get_ssl_library() { | 2442 | curlhelp_ssl_library curlhelp_get_ssl_library(void) { |
2442 | curl_version_info_data *version_data; | 2443 | curl_version_info_data *version_data; |
2443 | char *ssl_version; | 2444 | char *ssl_version; |
2444 | char *library; | 2445 | char *library; |