[monitoring-plugins] check_icmp: Fix compiler warning
RincewindsHat
git at monitoring-plugins.org
Sat Mar 4 21:10:11 CET 2023
Module: monitoring-plugins
Branch: master
Commit: d3a4bad51d72a3c5bcc06ceb5e0a823dcc24bf49
Author: RincewindsHat <12514511+RincewindsHat at users.noreply.github.com>
Date: Sun Feb 19 14:31:21 2023 +0100
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=d3a4bad
check_icmp: Fix compiler warning
This fixes a compiler warning with no real world impact.
The compiler complains about a missing return, which is correct, but
in that scenario the program would crash anyways, so this has no impact.
---
plugins-root/check_icmp.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 7f3c4b5..317cd53 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1430,20 +1430,21 @@ set_source_ip(char *arg)
static in_addr_t
get_ip_address(const char *ifname)
{
+ // TODO: Rewrite this so the function return an error and we exit somewhere else
+ struct sockaddr_in ip;
#if defined(SIOCGIFADDR)
struct ifreq ifr;
- struct sockaddr_in ip;
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));
- return ip.sin_addr.s_addr;
#else
errno = 0;
crash("Cannot get interface IP address on this platform.");
#endif
+ return ip.sin_addr.s_addr;
}
/*
More information about the Commits
mailing list