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 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'plugins-root') 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 -- cgit v1.2.3-74-g34f1 From ab62b2ce5da5adbbfcbb63922b06695a7b94e997 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 12 Mar 2023 19:31:45 +0100 Subject: Fixes for -Wuninitialized --- plugins-root/check_icmp.c | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins-root') diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index edfd6949..f96207be 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -1432,6 +1432,7 @@ get_ip_address(const char *ifname) { // TODO: Rewrite this so the function return an error and we exit somewhere else struct sockaddr_in ip; + ip.sin_addr.s_addr = 0; // Fake inititialization to make compiler happy #if defined(SIOCGIFADDR) struct ifreq ifr; -- cgit v1.2.3-74-g34f1 From cb5579793731e3320330551bb2f926be7c7d0378 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 18 Apr 2023 00:42:20 +0200 Subject: Refix spelling issues --- plugins-root/check_icmp.c | 2 +- plugins/check_ntp_peer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins-root') diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index f96207be..1d47e9fc 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -1432,7 +1432,7 @@ get_ip_address(const char *ifname) { // TODO: Rewrite this so the function return an error and we exit somewhere else struct sockaddr_in ip; - ip.sin_addr.s_addr = 0; // Fake inititialization to make compiler happy + ip.sin_addr.s_addr = 0; // Fake initialization to make compiler happy #if defined(SIOCGIFADDR) struct ifreq ifr; diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index 161b4950..49cb1008 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c @@ -585,7 +585,7 @@ int main(int argc, char *argv[]){ /* set socket timeout */ alarm (socket_timeout); - /* This returns either OK or WARNING (See comment preceeding ntp_request) */ + /* This returns either OK or WARNING (See comment preceding ntp_request) */ result = ntp_request(&offset, &offset_result, &jitter, &stratum, &num_truechimers); if(offset_result == STATE_UNKNOWN) { -- cgit v1.2.3-74-g34f1