[asterisk-commits] russell: trunk r292189 - in /trunk: ./ main/netsock2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 18 14:53:00 CDT 2010


Author: russell
Date: Mon Oct 18 14:52:58 2010
New Revision: 292189

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=292189
Log:
Merged revisions 292188 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r292188 | russell | 2010-10-18 14:50:04 -0500 (Mon, 18 Oct 2010) | 9 lines
  
  Resolve some compiler errors in ast_sockaddr_is_any().
  
  These errors came up once this function was used from within netsock2.c.
  The errors were like the following:
  
  netsock2.c:393: error: dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
  
  The usage of a union here avoids this problem.
........

Modified:
    trunk/   (props changed)
    trunk/main/netsock2.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/netsock2.c?view=diff&rev=292189&r1=292188&r2=292189
==============================================================================
--- trunk/main/netsock2.c (original)
+++ trunk/main/netsock2.c Mon Oct 18 14:52:58 2010
@@ -389,11 +389,16 @@
 
 int ast_sockaddr_is_any(const struct ast_sockaddr *addr)
 {
-	return (ast_sockaddr_is_ipv4(addr) &&
-		((const struct sockaddr_in *)&addr->ss)->sin_addr.s_addr ==
-		INADDR_ANY) ||
-	    (ast_sockaddr_is_ipv6(addr) &&
-	     IN6_IS_ADDR_UNSPECIFIED(&((const struct sockaddr_in6 *)&addr->ss)->sin6_addr));
+	union {
+		struct sockaddr_storage ss;
+		struct sockaddr_in sin;
+		struct sockaddr_in6 sin6;
+	} tmp_addr = {
+		.ss = addr->ss,
+	};
+
+	return (ast_sockaddr_is_ipv4(addr) && (tmp_addr.sin.sin_addr.s_addr == INADDR_ANY)) ||
+	    (ast_sockaddr_is_ipv6(addr) && IN6_IS_ADDR_UNSPECIFIED(&tmp_addr.sin6.sin6_addr));
 }
 
 int ast_sockaddr_hash(const struct ast_sockaddr *addr)




More information about the asterisk-commits mailing list