[asterisk-commits] tzafrir: branch 1.6.0 r217484 - in /branches/1.6.0: ./ res/res_phoneprov.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 9 15:15:39 CDT 2009


Author: tzafrir
Date: Wed Sep  9 15:15:37 2009
New Revision: 217484

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=217484
Log:
gcc 4.4 fix: union instead of cast

gcc 4.4 has more strict rules for aliasing. It doesn't like a 
struct sockaddr_in pointer pointing to a struct sockaddr. So we make it
a union.

Merged revisions 217445 via svnmerge from 
http://svn.digium.com/svn/asterisk/trunk

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/res/res_phoneprov.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/res/res_phoneprov.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.0/res/res_phoneprov.c?view=diff&rev=217484&r1=217483&r2=217484
==============================================================================
--- branches/1.6.0/res/res_phoneprov.c (original)
+++ branches/1.6.0/res/res_phoneprov.c Wed Sep  9 15:15:37 2009
@@ -409,15 +409,19 @@
 		/* Unless we are overridden by serveriface or serveraddr, we set the SERVER variable to
 		 * the IP address we are listening on that the phone contacted for this config file */
 		if (ast_strlen_zero(global_server)) {
-			struct sockaddr name;
-			socklen_t namelen = sizeof(name);
+			union {
+				struct sockaddr sa;
+				struct sockaddr_in sa_in;
+			} name;
+			socklen_t namelen = sizeof(name.sa);
 			int res;
 
-			if ((res = getsockname(ser->fd, &name, &namelen)))
+			if ((res = getsockname(ser->fd, &name.sa, &namelen)))
 				ast_log(LOG_WARNING, "Could not get server IP, breakage likely.\n");
 			else {
 				struct ast_var_t *var;
 
+				if ((var = ast_var_assign("SERVER", ast_inet_ntoa(name.sa_in.sin_addr))))
 				if ((var = ast_var_assign("SERVER", ast_inet_ntoa(((struct sockaddr_in *)&name)->sin_addr))))
 					AST_LIST_INSERT_TAIL(route->user->headp, var, entries);
 			}




More information about the asterisk-commits mailing list