/pidgin/main: a9d3726c3a8f: Clang warnings: clean up libpurple

Tomasz Wasilczyk twasilczyk at pidgin.im
Fri Oct 4 11:46:46 EDT 2013


Changeset: a9d3726c3a8fa0288b7da333a8adaaede0d81db1
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2013-10-04 17:46 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/a9d3726c3a8f

Description:

Clang warnings: clean up libpurple

diffstat:

 libpurple/ft.c                             |   9 +--
 libpurple/ft.h                             |  13 ++---
 libpurple/media/backend-fs2.c              |  70 ++++++++++++++++++++++++++++-
 libpurple/protocols/jabber/jabber.h        |   2 +-
 libpurple/protocols/jabber/si.c            |   6 +-
 libpurple/protocols/msn/msnutils.c         |   2 +-
 libpurple/protocols/mxit/chunk.c           |   2 +-
 libpurple/protocols/myspace/myspace.c      |   3 +-
 libpurple/protocols/oscar/family_feedbag.c |   4 +-
 libpurple/protocols/oscar/oscar.c          |  14 +++---
 libpurple/protocols/oscar/tlv.c            |  10 ++--
 libpurple/protocols/oscar/userinfo.c       |  20 ++++----
 libpurple/util.c                           |   6 +-
 13 files changed, 110 insertions(+), 51 deletions(-)

diffs (truncated from 449 to 300 lines):

diff --git a/libpurple/ft.c b/libpurple/ft.c
--- a/libpurple/ft.c
+++ b/libpurple/ft.c
@@ -844,7 +844,7 @@ purple_xfer_get_progress(const PurpleXfe
 			(double)purple_xfer_get_size(xfer));
 }
 
-unsigned int
+guint16
 purple_xfer_get_local_port(const PurpleXfer *xfer)
 {
 	g_return_val_if_fail(xfer != NULL, -1);
@@ -860,7 +860,7 @@ purple_xfer_get_remote_ip(const PurpleXf
 	return xfer->remote_ip;
 }
 
-unsigned int
+guint16
 purple_xfer_get_remote_port(const PurpleXfer *xfer)
 {
 	g_return_val_if_fail(xfer != NULL, -1);
@@ -981,7 +981,7 @@ purple_xfer_set_size(PurpleXfer *xfer, g
 }
 
 void
-purple_xfer_set_local_port(PurpleXfer *xfer, unsigned int local_port)
+purple_xfer_set_local_port(PurpleXfer *xfer, guint16 local_port)
 {
 	g_return_if_fail(xfer != NULL);
 
@@ -1509,8 +1509,7 @@ purple_xfer_prpl_ready(PurpleXfer *xfer)
 }
 
 void
-purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip,
-				unsigned int port)
+purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip, guint16 port)
 {
 	PurpleInputCondition cond;
 	PurpleXferType type;
diff --git a/libpurple/ft.h b/libpurple/ft.h
--- a/libpurple/ft.h
+++ b/libpurple/ft.h
@@ -145,8 +145,8 @@ struct _PurpleXfer
 	FILE *dest_fp;                /**< The destination file pointer.       */
 
 	char *remote_ip;              /**< The remote IP address.              */
-	int local_port;               /**< The local port.                     */
-	int remote_port;              /**< The remote port.                    */
+	guint16 local_port;           /**< The local port.                     */
+	guint16 remote_port;          /**< The remote port.                    */
 
 	int fd;                       /**< The socket file descriptor.         */
 	int watcher;                  /**< Watcher.                            */
@@ -394,7 +394,7 @@ double purple_xfer_get_progress(const Pu
  *
  * @return The port number on this end.
  */
-unsigned int purple_xfer_get_local_port(const PurpleXfer *xfer);
+guint16 purple_xfer_get_local_port(const PurpleXfer *xfer);
 
 /**
  * Returns the remote IP address in the file transfer.
@@ -412,7 +412,7 @@ const char *purple_xfer_get_remote_ip(co
  *
  * @return The port number on the other end.
  */
-unsigned int purple_xfer_get_remote_port(const PurpleXfer *xfer);
+guint16 purple_xfer_get_remote_port(const PurpleXfer *xfer);
 
 /**
  * Returns the time the transfer of a file started.
@@ -502,7 +502,7 @@ void purple_xfer_set_size(PurpleXfer *xf
  * @param xfer          The file transfer.
  * @param local_port    The local port.
  */
-void purple_xfer_set_local_port(PurpleXfer *xfer, unsigned int local_port);
+void purple_xfer_set_local_port(PurpleXfer *xfer, guint16 local_port);
 
 /**
  * Sets the current working position in the active file transfer.  This
@@ -668,8 +668,7 @@ purple_xfer_read_file(PurpleXfer *xfer, 
  * @param ip   The IP address to connect to.
  * @param port The port to connect to.
  */
-void purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip,
-					 unsigned int port);
+void purple_xfer_start(PurpleXfer *xfer, int fd, const char *ip, guint16 port);
 
 /**
  * Ends a file transfer.
diff --git a/libpurple/media/backend-fs2.c b/libpurple/media/backend-fs2.c
--- a/libpurple/media/backend-fs2.c
+++ b/libpurple/media/backend-fs2.c
@@ -181,6 +181,66 @@ static void
 purple_media_backend_fs2_init(PurpleMediaBackendFs2 *self)
 {}
 
+static FsCandidateType
+purple_media_candidate_type_to_fs(PurpleMediaCandidateType type)
+{
+	switch (type) {
+		case PURPLE_MEDIA_CANDIDATE_TYPE_HOST:
+			return FS_CANDIDATE_TYPE_HOST;
+		case PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX:
+			return FS_CANDIDATE_TYPE_SRFLX;
+		case PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX:
+			return FS_CANDIDATE_TYPE_PRFLX;
+		case PURPLE_MEDIA_CANDIDATE_TYPE_RELAY:
+			return FS_CANDIDATE_TYPE_RELAY;
+		case PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST:
+			return FS_CANDIDATE_TYPE_MULTICAST;
+	}
+	g_return_val_if_reached(FS_CANDIDATE_TYPE_HOST);
+}
+
+static PurpleMediaCandidateType
+purple_media_candidate_type_from_fs(FsCandidateType type)
+{
+	switch (type) {
+		case FS_CANDIDATE_TYPE_HOST:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_HOST;
+		case FS_CANDIDATE_TYPE_SRFLX:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_SRFLX;
+		case FS_CANDIDATE_TYPE_PRFLX:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_PRFLX;
+		case FS_CANDIDATE_TYPE_RELAY:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_RELAY;
+		case FS_CANDIDATE_TYPE_MULTICAST:
+			return PURPLE_MEDIA_CANDIDATE_TYPE_MULTICAST;
+	}
+	g_return_val_if_reached(PURPLE_MEDIA_CANDIDATE_TYPE_HOST);
+}
+
+static FsNetworkProtocol
+purple_media_network_protocol_to_fs(PurpleMediaNetworkProtocol protocol)
+{
+	switch (protocol) {
+		case PURPLE_MEDIA_NETWORK_PROTOCOL_UDP:
+			return FS_NETWORK_PROTOCOL_UDP;
+		case PURPLE_MEDIA_NETWORK_PROTOCOL_TCP:
+			return FS_NETWORK_PROTOCOL_TCP;
+	}
+	g_return_val_if_reached(FS_NETWORK_PROTOCOL_TCP);
+}
+
+static PurpleMediaNetworkProtocol
+purple_media_network_protocol_from_fs(FsNetworkProtocol protocol)
+{
+	switch (protocol) {
+		case FS_NETWORK_PROTOCOL_UDP:
+			return PURPLE_MEDIA_NETWORK_PROTOCOL_UDP;
+		case FS_NETWORK_PROTOCOL_TCP:
+			return PURPLE_MEDIA_NETWORK_PROTOCOL_TCP;
+	}
+	g_return_val_if_reached(PURPLE_MEDIA_NETWORK_PROTOCOL_TCP);
+}
+
 #if GST_CHECK_VERSION(1,0,0)
 static GstPadProbeReturn
 event_probe_cb(GstPad *srcpad, GstPadProbeInfo *info, gpointer unused)
@@ -554,8 +614,8 @@ candidate_to_fs(PurpleMediaCandidate *ca
 			NULL);
 
 	fscandidate = fs_candidate_new(foundation,
-			component_id, type,
-			proto, ip, port);
+			component_id, purple_media_candidate_type_to_fs(type),
+			purple_media_network_protocol_to_fs(proto), ip, port);
 
 	fscandidate->base_ip = base_ip;
 	fscandidate->base_port = base_port;
@@ -592,8 +652,10 @@ candidate_from_fs(FsCandidate *fscandida
 		return NULL;
 
 	candidate = purple_media_candidate_new(fscandidate->foundation,
-		fscandidate->component_id, fscandidate->type,
-		fscandidate->proto, fscandidate->ip, fscandidate->port);
+		fscandidate->component_id,
+		purple_media_candidate_type_from_fs(fscandidate->type),
+		purple_media_network_protocol_from_fs(fscandidate->proto),
+		fscandidate->ip, fscandidate->port);
 	g_object_set(candidate,
 			"base-ip", fscandidate->base_ip,
 			"base-port", fscandidate->base_port,
diff --git a/libpurple/protocols/jabber/jabber.h b/libpurple/protocols/jabber/jabber.h
--- a/libpurple/protocols/jabber/jabber.h
+++ b/libpurple/protocols/jabber/jabber.h
@@ -298,7 +298,7 @@ typedef struct _JabberIdentity
 typedef struct _JabberBytestreamsStreamhost {
 	char *jid;
 	char *host;
-	int port;
+	guint16 port;
 	char *zeroconf;
 } JabberBytestreamsStreamhost;
 
diff --git a/libpurple/protocols/jabber/si.c b/libpurple/protocols/jabber/si.c
--- a/libpurple/protocols/jabber/si.c
+++ b/libpurple/protocols/jabber/si.c
@@ -58,7 +58,7 @@ typedef struct _JabberSIXfer {
 		STREAM_METHOD_UNKNOWN     = 0,
 		STREAM_METHOD_BYTESTREAMS = 2 << 1,
 		STREAM_METHOD_IBB         = 2 << 2,
-		STREAM_METHOD_UNSUPPORTED = 2 << 31
+		STREAM_METHOD_UNSUPPORTED = 2 << 30
 	} stream_method;
 
 	GList *streamhosts;
@@ -616,11 +616,11 @@ jabber_si_xfer_bytestreams_send_read_cb(
 		return;
 	}
 
-	purple_debug_info("jabber", "going to test %hu different methods\n", jsx->rxqueue[1]);
+	purple_debug_info("jabber", "going to test %u different methods\n", (guint)jsx->rxqueue[1]);
 
 	for(i=0; i<jsx->rxqueue[1]; i++) {
 
-		purple_debug_info("jabber", "testing %hu\n", jsx->rxqueue[i+2]);
+		purple_debug_info("jabber", "testing %u\n", (guint)jsx->rxqueue[i+2]);
 		if(jsx->rxqueue[i+2] == 0x00) {
 			g_free(jsx->rxqueue);
 			jsx->rxlen = 0;
diff --git a/libpurple/protocols/msn/msnutils.c b/libpurple/protocols/msn/msnutils.c
--- a/libpurple/protocols/msn/msnutils.c
+++ b/libpurple/protocols/msn/msnutils.c
@@ -124,7 +124,7 @@ msn_parse_format(const char *mime, char 
 			}
 
 			g_snprintf(tag, sizeof(tag),
-				"<FONT COLOR=\"#%02hx%02hx%02hx\">",
+				"<FONT COLOR=\"#%02x%02x%02x\">",
 				colors[0] & 0xFF, colors[1] & 0xFF,
 				colors[2] & 0xFF);
 
diff --git a/libpurple/protocols/mxit/chunk.c b/libpurple/protocols/mxit/chunk.c
--- a/libpurple/protocols/mxit/chunk.c
+++ b/libpurple/protocols/mxit/chunk.c
@@ -382,7 +382,7 @@ int mxit_chunk_create_senddirect( char* 
  */
 int mxit_chunk_create_set_avatar( char* chunkdata, const unsigned char* data, int datalen )
 {
-	const char	fileid[MXIT_CHUNK_FILEID_LEN];
+	char	fileid[MXIT_CHUNK_FILEID_LEN];
 	int			pos = 0;
 
 	/* id [8 bytes] */
diff --git a/libpurple/protocols/myspace/myspace.c b/libpurple/protocols/myspace/myspace.c
--- a/libpurple/protocols/myspace/myspace.c
+++ b/libpurple/protocols/myspace/myspace.c
@@ -514,8 +514,7 @@ msim_status_types(PurpleAccount *acct)
 		(*((buf)) = (unsigned char)((data)>>24)&0xff), \
 		(*((buf)+1) = (unsigned char)((data)>>16)&0xff), \
 		(*((buf)+2) = (unsigned char)((data)>>8)&0xff), \
-		(*((buf)+3) = (unsigned char)(data)&0xff), \
-		4)
+		(*((buf)+3) = (unsigned char)(data)&0xff))
 
 /**
  * Compute the base64'd login challenge response based on username, password, nonce, and IPs.
diff --git a/libpurple/protocols/oscar/family_feedbag.c b/libpurple/protocols/oscar/family_feedbag.c
--- a/libpurple/protocols/oscar/family_feedbag.c
+++ b/libpurple/protocols/oscar/family_feedbag.c
@@ -1161,8 +1161,8 @@ int aim_ssi_seticon(OscarData *od, const
 
 	/* Need to add the 0x00d5 TLV to the TLV chain */
 	csumdata = (guint8 *)g_malloc((iconsumlen+2)*sizeof(guint8));
-	aimutil_put8(&csumdata[0], 0x00);
-	aimutil_put8(&csumdata[1], iconsumlen);
+	(void)aimutil_put8(&csumdata[0], 0x00);
+	(void)aimutil_put8(&csumdata[1], iconsumlen);
 	memcpy(&csumdata[2], iconsum, iconsumlen);
 	aim_tlvlist_replace_raw(&tmp->data, 0x00d5, (iconsumlen+2) * sizeof(guint8), csumdata);
 	g_free(csumdata);
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -1665,7 +1665,7 @@ incomingim_chan4(OscarData *od, FlapConn
 
 	purple_debug_info("oscar",
 					"Received a channel 4 message of type 0x%02hx.\n",
-					args->type);
+					(guint16)args->type);
 
 	/*
 	 * Split up the message at the delimeter character, then convert each
@@ -1910,7 +1910,7 @@ incomingim_chan4(OscarData *od, FlapConn
 		default: {
 			purple_debug_info("oscar",
 					   "Received a channel 4 message of unknown type "
-					   "(type 0x%02hx).\n", args->type & 0xFF);
+					   "(type 0x%02x).\n", args->type & 0xFF);
 		} break;
 	}
 
@@ -2260,7 +2260,7 @@ static int purple_chatnav_info(OscarData
 			exchangecount = va_arg(ap, int);
 			exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);
 
-			g_string_append_printf(msg, "chat info: Max Concurrent Rooms: %hd, Exchange List (%d total): ", maxrooms, exchangecount);



More information about the Commits mailing list