[asterisk-commits] tzafrir: trunk r217445 - /trunk/res/res_phoneprov.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 9 13:52:50 CDT 2009


Author: tzafrir
Date: Wed Sep  9 13:52:48 2009
New Revision: 217445

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=217445
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.

Modified:
    trunk/res/res_phoneprov.c

Modified: trunk/res/res_phoneprov.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/res/res_phoneprov.c?view=diff&rev=217445&r1=217444&r2=217445
==============================================================================
--- trunk/res/res_phoneprov.c (original)
+++ trunk/res/res_phoneprov.c Wed Sep  9 13:52:48 2009
@@ -487,17 +487,20 @@
 		/* 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;
 				struct extension *exten_iter;
 
-				if ((var = ast_var_assign("SERVER", ast_inet_ntoa(((struct sockaddr_in *)&name)->sin_addr)))) {
+				if ((var = ast_var_assign("SERVER", ast_inet_ntoa(name.sa_in.sin_addr)))) {
 					AST_LIST_TRAVERSE(&route->user->extensions, exten_iter, entry) {
 						AST_LIST_INSERT_TAIL(exten_iter->headp, var, entries);
 					}




More information about the asterisk-commits mailing list