[Nagiosplug-checkins] SF.net SVN: nagiosplug: [1895] nagiosplug/trunk/plugins-root/check_icmp.c

hweiss at users.sourceforge.net hweiss at users.sourceforge.net
Tue Jan 8 02:43:49 CET 2008


Revision: 1895
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1895&view=rev
Author:   hweiss
Date:     2008-01-07 17:43:49 -0800 (Mon, 07 Jan 2008)

Log Message:
-----------
Get rid of a cast which increases the required alignment.

Modified Paths:
--------------
    nagiosplug/trunk/plugins-root/check_icmp.c

Modified: nagiosplug/trunk/plugins-root/check_icmp.c
===================================================================
--- nagiosplug/trunk/plugins-root/check_icmp.c	2008-01-08 01:40:21 UTC (rev 1894)
+++ nagiosplug/trunk/plugins-root/check_icmp.c	2008-01-08 01:43:49 UTC (rev 1895)
@@ -1139,12 +1139,14 @@
 {
 #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.");


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list