From 907b933a87ae21ad776c53a2dd7f04beb220b6bf Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 12 Mar 2023 20:12:37 +0100 Subject: Fixes for -Wunused-parameters --- plugins-root/check_dhcp.c | 12 ++++++------ plugins-root/check_icmp.c | 4 ++++ plugins/check_curl.c | 9 ++++++--- plugins/check_ntp_peer.c | 6 +++--- plugins/check_ups.c | 14 +++++++------- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index ad673237..2d742349 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c @@ -229,7 +229,7 @@ struct in_addr requested_address; int process_arguments(int, char **); int call_getopt(int, char **); -int validate_arguments(int, int); +int validate_arguments(int); void print_usage(void); void print_help(void); @@ -1059,8 +1059,8 @@ int process_arguments(int argc, char **argv){ return ERROR; arg_index = call_getopt(argc,argv); - return validate_arguments(argc,arg_index); - } + return validate_arguments(argc); +} @@ -1158,13 +1158,13 @@ int call_getopt(int argc, char **argv){ } -int validate_arguments(int argc, int arg_index){ +int validate_arguments(int argc){ - if(argc-optind > 0) + if(argc - optind > 0) usage(_("Got unexpected non-option argument")); return OK; - } +} #if defined(__sun__) || defined(__solaris__) || defined(__hpux__) diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 9ceb35b2..edfd6949 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -1436,11 +1436,15 @@ get_ip_address(const char *ifname) struct ifreq ifr; strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); + ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; + if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) crash("Cannot determine IP address of interface %s", ifname); + memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); #else + (void) ifname; errno = 0; crash("Cannot get interface IP address on this platform."); #endif diff --git a/plugins/check_curl.c b/plugins/check_curl.c index b7137145..41c25d9c 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -244,7 +244,7 @@ void curlhelp_freewritebuffer (curlhelp_write_curlbuf*); int curlhelp_initreadbuffer (curlhelp_read_curlbuf *, const char *, size_t); int curlhelp_buffer_read_callback (void *, size_t , size_t , void *); void curlhelp_freereadbuffer (curlhelp_read_curlbuf *); -curlhelp_ssl_library curlhelp_get_ssl_library (CURL*); +curlhelp_ssl_library curlhelp_get_ssl_library (); const char* curlhelp_get_ssl_library_string (curlhelp_ssl_library); int net_noopenssl_check_certificate (cert_ptr_union*, int, int); @@ -297,6 +297,7 @@ main (int argc, char **argv) int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) { + (void) preverify_ok; /* TODO: we get all certificates of the chain, so which ones * should we test? * TODO: is the last certificate always the server certificate? @@ -321,6 +322,8 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm) { + (void) curl; // ignore unused parameter + (void) parm; // ignore unused parameter SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback); return CURLE_OK; @@ -646,7 +649,7 @@ check_http (void) } /* detect SSL library used by libcurl */ - ssl_library = curlhelp_get_ssl_library (curl); + ssl_library = curlhelp_get_ssl_library (); /* try hard to get a stack of certificates to verify against */ if (check_cert) { @@ -2381,7 +2384,7 @@ get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_wri /* TODO: is there a better way in libcurl to check for the SSL library? */ curlhelp_ssl_library -curlhelp_get_ssl_library (CURL* curl) +curlhelp_get_ssl_library () { curl_version_info_data* version_data; char *ssl_version; diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index eafafdc0..161b4950 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c @@ -199,7 +199,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){ * status is pretty much useless as syncsource_found is a global variable * used later in main to check is the server was synchronized. It works * so I left it alone */ -int ntp_request(const char *host, double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){ +int ntp_request(double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){ int conn=-1, i, npeers=0, num_candidates=0; double tmp_offset = 0; int min_peer_sel=PEER_INCLUDED; @@ -585,8 +585,8 @@ int main(int argc, char *argv[]){ /* set socket timeout */ alarm (socket_timeout); - /* This returns either OK or WARNING (See comment proceeding ntp_request) */ - result = ntp_request(server_address, &offset, &offset_result, &jitter, &stratum, &num_truechimers); + /* This returns either OK or WARNING (See comment preceeding ntp_request) */ + result = ntp_request(&offset, &offset_result, &jitter, &stratum, &num_truechimers); if(offset_result == STATE_UNKNOWN) { /* if there's no sync peer (this overrides ntp_request output): */ diff --git a/plugins/check_ups.c b/plugins/check_ups.c index 12bce217..68737c4b 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c @@ -89,7 +89,7 @@ char *ups_status; int temp_output_c = 0; int determine_status (void); -int get_ups_variable (const char *, char *, size_t); +int get_ups_variable (const char *, char *); int process_arguments (int, char **); int validate_arguments (void); @@ -189,7 +189,7 @@ main (int argc, char **argv) } /* get the ups utility voltage if possible */ - res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer)); + res=get_ups_variable ("input.voltage", temp_buffer); if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY; else if (res != OK) return STATE_CRITICAL; @@ -224,7 +224,7 @@ main (int argc, char **argv) } /* get the ups battery percent if possible */ - res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer)); + res=get_ups_variable ("battery.charge", temp_buffer); if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT; else if ( res != OK) return STATE_CRITICAL; @@ -253,7 +253,7 @@ main (int argc, char **argv) } /* get the ups load percent if possible */ - res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer)); + res=get_ups_variable ("ups.load", temp_buffer); if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT; else if ( res != OK) return STATE_CRITICAL; @@ -282,7 +282,7 @@ main (int argc, char **argv) } /* get the ups temperature if possible */ - res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer)); + res=get_ups_variable ("ups.temperature", temp_buffer); if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP; else if ( res != OK) return STATE_CRITICAL; @@ -342,7 +342,7 @@ determine_status (void) char *ptr; int res; - res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); + res=get_ups_variable ("ups.status", recv_buffer); if (res == NOSUCHVAR) return OK; if (res != STATE_OK) { printf ("%s\n", _("Invalid response received from host")); @@ -388,7 +388,7 @@ determine_status (void) /* gets a variable value for a specific UPS */ int -get_ups_variable (const char *varname, char *buf, size_t buflen) +get_ups_variable (const char *varname, char *buf) { /* char command[MAX_INPUT_BUFFER]; */ char temp_buffer[MAX_INPUT_BUFFER]; -- cgit v1.2.3-74-g34f1