Sadly we can't dereference a pointer cast and use it as an lvalue without getting...
author <simon.perreault@viagenie.ca> <>
Fri, 9 Jul 2010 12:56:18 +0000 (12:56 +0000)
committer <simon.perreault@viagenie.ca> <>
Fri, 9 Jul 2010 12:56:18 +0000 (12:56 +0000)
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()...

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@274909 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/netsock2.c

index 4d93a91..ba671c1 100644 (file)
@@ -489,7 +489,7 @@ int ast_sockaddr_to_sin(const struct ast_sockaddr *addr,
 
 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");