From: Holger Weiss Date: Tue, 8 Jan 2008 01:43:49 +0000 (+0000) Subject: Get rid of a cast which increases the required alignment. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5da79db21aa37e2663662f96ff328ce127db25e0;p=nagiosplug.git Get rid of a cast which increases the required alignment. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1895 f882894a-f735-0410-b71e-b25c423dba1c --- diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 700fe8b..c0b29f2 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -1139,12 +1139,14 @@ get_ip_address(const char *ifname) { #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); - return ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr; + 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.");