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.
This commit is contained in:
RincewindsHat 2023-02-19 14:31:21 +01:00
parent 9a73a94258
commit d3a4bad51d

View file

@ -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;
}
/*