Code

Get rid of a cast which increases the required alignment.
authorHolger Weiss <hweiss@users.sourceforge.net>
Tue, 8 Jan 2008 01:43:49 +0000 (01:43 +0000)
committerHolger Weiss <hweiss@users.sourceforge.net>
Tue, 8 Jan 2008 01:43:49 +0000 (01:43 +0000)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1895 f882894a-f735-0410-b71e-b25c423dba1c

plugins-root/check_icmp.c

index 700fe8b689516ab0ef0a75f083eaac54b899a418..c0b29f25cd4b60f4b733fb4b515ca463c9246744 100644 (file)
@@ -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.");