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

[email protected]
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
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.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.