[asterisk-commits] simon.perreault: trunk r274909 - /trunk/main/netsock2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 9 07:56:21 CDT 2010


Author: simon.perreault
Date: Fri Jul  9 07:56:18 2010
New Revision: 274909

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=274909
Log:
Sadly we can't dereference a pointer cast and use it as an lvalue without getting this
warning (at least with gcc 4.4.4):

netsock2.c:492: warning: dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules

So we're back to using memcpy()...

Modified:
    trunk/main/netsock2.c

Modified: trunk/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/netsock2.c?view=diff&rev=274909&r1=274908&r2=274909
==============================================================================
--- trunk/main/netsock2.c (original)
+++ trunk/main/netsock2.c Fri Jul  9 07:56:18 2010
@@ -489,7 +489,7 @@
 
 void ast_sockaddr_from_sin(struct ast_sockaddr *addr, const struct sockaddr_in *sin)
 {
-	*((struct sockaddr_in *)&addr->ss) = *sin;
+	memcpy(&addr->ss, sin, sizeof(*sin));
 
 	if (addr->ss.ss_family != AF_INET) {
 		ast_log(LOG_DEBUG, "Address family is not AF_INET\n");




More information about the asterisk-commits mailing list