/pidgin/main: fdd1f3a3c6df: Fix the last ppc64 warning

Tomasz Wasilczyk twasilczyk at pidgin.im
Wed Feb 12 22:27:35 EST 2014


Changeset: fdd1f3a3c6df13d85a45f3da09f728e2c9bc9208
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-02-13 04:27 +0100
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/fdd1f3a3c6df

Description:

Fix the last ppc64 warning

diffstat:

 libpurple/internal.h                 |   8 ++++++++
 libpurple/protocols/bonjour/jabber.c |  23 +++++++++++------------
 2 files changed, 19 insertions(+), 12 deletions(-)

diffs (68 lines):

diff --git a/libpurple/internal.h b/libpurple/internal.h
--- a/libpurple/internal.h
+++ b/libpurple/internal.h
@@ -143,6 +143,14 @@
 
 #include <glib-object.h>
 
+typedef union
+{
+	struct sockaddr sa;
+	struct sockaddr_in in;
+	struct sockaddr_in6 in6;
+	struct sockaddr_storage storage;
+} common_sockaddr_t;
+
 #define PURPLE_WEBSITE "https://pidgin.im/"
 #define PURPLE_DEVEL_WEBSITE "https://developer.pidgin.im/"
 
diff --git a/libpurple/protocols/bonjour/jabber.c b/libpurple/protocols/bonjour/jabber.c
--- a/libpurple/protocols/bonjour/jabber.c
+++ b/libpurple/protocols/bonjour/jabber.c
@@ -634,8 +634,8 @@ static void
 _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition)
 {
 	BonjourJabber *jdata = data;
-	struct sockaddr_storage their_addr; /* connector's address information */
-	socklen_t sin_size = sizeof(struct sockaddr_storage);
+	common_sockaddr_t their_addr; /* connector's address information */
+	socklen_t sin_size = sizeof(common_sockaddr_t);
 	int client_socket;
 	int flags;
 #ifdef HAVE_INET_NTOP
@@ -652,7 +652,7 @@ static void
 
 	memset(&their_addr, 0, sin_size);
 
-	if ((client_socket = accept(server_socket, (struct sockaddr*)&their_addr, &sin_size)) == -1)
+	if ((client_socket = accept(server_socket, &their_addr.sa, &sin_size)) == -1)
 		return;
 
 	flags = fcntl(client_socket, F_GETFL);
@@ -663,18 +663,17 @@ static void
 
 	/* Look for the buddy that has opened the conversation and fill information */
 #ifdef HAVE_INET_NTOP
-	if (their_addr.ss_family == AF_INET6) {
-		address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in6 *)&their_addr)->sin6_addr,
-			addrstr, sizeof(addrstr));
+	if (their_addr.sa.sa_family == AF_INET6) {
+		address_text = inet_ntop(their_addr.sa.sa_family,
+			&their_addr.in6.sin6_addr, addrstr, sizeof(addrstr));
 
-		append_iface_if_linklocal(addrstr,
-			((struct sockaddr_in6 *)&their_addr)->sin6_scope_id);
+		append_iface_if_linklocal(addrstr, their_addr.in6.sin6_scope_id);
+	} else {
+		address_text = inet_ntop(their_addr.sa.sa_family,
+			&their_addr.in.sin_addr, addrstr, sizeof(addrstr));
 	}
-	else
-		address_text = inet_ntop(their_addr.ss_family, &((struct sockaddr_in *)&their_addr)->sin_addr,
-			addrstr, sizeof(addrstr));
 #else
-	address_text = inet_ntoa(((struct sockaddr_in *)&their_addr)->sin_addr);
+	address_text = inet_ntoa(their_addr.in.sin_addr);
 #endif
 	purple_debug_info("bonjour", "Received incoming connection from %s.\n", address_text);
 	mbba = g_new0(struct _match_buddies_by_address_t, 1);



More information about the Commits mailing list