Clang warnings: clean up libpurple

Fri, 04 Oct 2013 17:46:37 +0200

author
Tomasz Wasilczyk <twasilczyk@pidgin.im>
date
Fri, 04 Oct 2013 17:46:37 +0200
changeset 34457
a9d3726c3a8f
parent 34456
d69aa7d3530c
child 34458
5c9d451155c5

Clang warnings: clean up libpurple

libpurple/ft.c file | annotate | diff | comparison | revisions
libpurple/ft.h file | annotate | diff | comparison | revisions
libpurple/media/backend-fs2.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/jabber.h file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/si.c file | annotate | diff | comparison | revisions
libpurple/protocols/msn/msnutils.c file | annotate | diff | comparison | revisions
libpurple/protocols/mxit/chunk.c file | annotate | diff | comparison | revisions
libpurple/protocols/myspace/myspace.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/family_feedbag.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/oscar.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/tlv.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/userinfo.c file | annotate | diff | comparison | revisions
libpurple/util.c file | annotate | diff | comparison | revisions
--- a/libpurple/ft.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/ft.c	Fri Oct 04 17:46:37 2013 +0200
@@ -844,7 +844,7 @@
 			(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 @@
 	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 @@
 }
 
 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 @@
 }
 
 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;
--- a/libpurple/ft.h	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/ft.h	Fri Oct 04 17:46:37 2013 +0200
@@ -145,8 +145,8 @@
 	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 @@
  *
  * @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 @@
  *
  * @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 @@
  * @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 @@
  * @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.
--- a/libpurple/media/backend-fs2.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/media/backend-fs2.c	Fri Oct 04 17:46:37 2013 +0200
@@ -181,6 +181,66 @@
 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 @@
 			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 @@
 		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,
--- a/libpurple/protocols/jabber/jabber.h	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/protocols/jabber/jabber.h	Fri Oct 04 17:46:37 2013 +0200
@@ -298,7 +298,7 @@
 typedef struct _JabberBytestreamsStreamhost {
 	char *jid;
 	char *host;
-	int port;
+	guint16 port;
 	char *zeroconf;
 } JabberBytestreamsStreamhost;
 
--- a/libpurple/protocols/jabber/si.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/protocols/jabber/si.c	Fri Oct 04 17:46:37 2013 +0200
@@ -58,7 +58,7 @@
 		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 @@
 		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;
--- a/libpurple/protocols/msn/msnutils.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/protocols/msn/msnutils.c	Fri Oct 04 17:46:37 2013 +0200
@@ -124,7 +124,7 @@
 			}
 
 			g_snprintf(tag, sizeof(tag),
-				"<FONT COLOR=\"#%02hx%02hx%02hx\">",
+				"<FONT COLOR=\"#%02x%02x%02x\">",
 				colors[0] & 0xFF, colors[1] & 0xFF,
 				colors[2] & 0xFF);
 
--- a/libpurple/protocols/mxit/chunk.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/protocols/mxit/chunk.c	Fri Oct 04 17:46:37 2013 +0200
@@ -382,7 +382,7 @@
  */
 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] */
--- a/libpurple/protocols/myspace/myspace.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/protocols/myspace/myspace.c	Fri Oct 04 17:46:37 2013 +0200
@@ -514,8 +514,7 @@
 		(*((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.
--- a/libpurple/protocols/oscar/family_feedbag.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/protocols/oscar/family_feedbag.c	Fri Oct 04 17:46:37 2013 +0200
@@ -1161,8 +1161,8 @@
 
 	/* 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);
--- a/libpurple/protocols/oscar/oscar.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/protocols/oscar/oscar.c	Fri Oct 04 17:46:37 2013 +0200
@@ -1665,7 +1665,7 @@
 
 	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 @@
 		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 @@
 			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);
+			g_string_append_printf(msg, "chat info: Max Concurrent Rooms: %d, Exchange List (%d total): ", (int)maxrooms, exchangecount);
 			for (i = 0; i < exchangecount; i++) {
 				g_string_append_printf(msg, "%hu", exchanges[i].number);
 				if (exchanges[i].name) {
@@ -2301,9 +2301,9 @@
 			ck = va_arg(ap, char *);
 
 			purple_debug_misc("oscar",
-					"created room: %s %hu %hu %hu %u %hu %hu %hu %hu %s %s\n",
+					"created room: %s %hu %hu %hu %u %hu %hu %u %hu %s %s\n",
 					fqcn ? fqcn : "(null)", exchange, instance, flags, createtime,
-					maxmsglen, maxoccupancy, createperms, unknown,
+					maxmsglen, maxoccupancy, (guint)createperms, unknown,
 					name ? name : "(null)", ck);
 			aim_chat_join(od, exchange, ck, instance);
 			}
@@ -3900,7 +3900,7 @@
 					if (perm_deny != 0 && perm_deny != purple_account_get_privacy_type(account))
 					{
 						purple_debug_info("oscar",
-								   "ssi: changing permdeny from %d to %hu\n", purple_account_get_privacy_type(account), perm_deny);
+								   "ssi: changing permdeny from %d to %u\n", purple_account_get_privacy_type(account), (guint)perm_deny);
 						purple_account_set_privacy_type(account, perm_deny);
 					}
 				}
@@ -4164,7 +4164,7 @@
 	va_end(ap);
 
 	purple_debug_info("oscar",
-			   "ssi: received authorization reply from %s.  Reply is 0x%04hx\n", bn, reply);
+			   "ssi: received authorization reply from %s.  Reply is 0x%02hx\n", bn, (guint16)reply);
 
 	buddy = purple_find_buddy(purple_connection_get_account(gc), bn);
 	if (buddy && (purple_buddy_get_alias_only(buddy)))
--- a/libpurple/protocols/oscar/tlv.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/protocols/oscar/tlv.c	Fri Oct 04 17:46:37 2013 +0200
@@ -319,7 +319,7 @@
 {
 	guint8 v8[1];
 
-	aimutil_put8(v8, value);
+	(void)aimutil_put8(v8, value);
 
 	return aim_tlvlist_add_raw(list, type, 1, v8);
 }
@@ -336,7 +336,7 @@
 {
 	guint8 v16[2];
 
-	aimutil_put16(v16, value);
+	(void)aimutil_put16(v16, value);
 
 	return aim_tlvlist_add_raw(list, type, 2, v16);
 }
@@ -353,7 +353,7 @@
 {
 	guint8 v32[4];
 
-	aimutil_put32(v32, value);
+	(void)aimutil_put32(v32, value);
 
 	return aim_tlvlist_add_raw(list, type, 4, v32);
 }
@@ -585,7 +585,7 @@
 {
 	guint8 v8[1];
 
-	aimutil_put8(v8, value);
+	(void)aimutil_put8(v8, value);
 
 	return aim_tlvlist_replace_raw(list, type, 1, v8);
 }
@@ -604,7 +604,7 @@
 {
 	guint8 v32[4];
 
-	aimutil_put32(v32, value);
+	(void)aimutil_put32(v32, value);
 
 	return aim_tlvlist_replace_raw(list, type, 4, v32);
 }
--- a/libpurple/protocols/oscar/userinfo.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/protocols/oscar/userinfo.c	Fri Oct 04 17:46:37 2013 +0200
@@ -335,11 +335,11 @@
 
 	if ((bi != NULL) && (bi->ipaddr != 0)) {
 		char tmp2[40];
-		sprintf(tmp2, "%hhu.%hhu.%hhu.%hhu",
-				(bi->ipaddr & 0xff000000) >> 24,
-				(bi->ipaddr & 0x00ff0000) >> 16,
-				(bi->ipaddr & 0x0000ff00) >> 8,
-				(bi->ipaddr & 0x000000ff));
+		sprintf(tmp2, "%u.%u.%u.%u",
+			0xFF & ((bi->ipaddr & 0xff000000) >> 24),
+			0xFF & ((bi->ipaddr & 0x00ff0000) >> 16),
+			0xFF & ((bi->ipaddr & 0x0000ff00) >> 8),
+			0xFF & (bi->ipaddr & 0x000000ff));
 		purple_notify_user_info_add_pair_plaintext(user_info, _("IP Address"), tmp2);
 	}
 
@@ -399,11 +399,11 @@
 	oscar_user_info_convert_and_add(account, od, user_info, _("Nick"), info->nick);
 	if ((bi != NULL) && (bi->ipaddr != 0)) {
 		char tstr[40];
-		sprintf(tstr, "%hhu.%hhu.%hhu.%hhu",
-				(bi->ipaddr & 0xff000000) >> 24,
-				(bi->ipaddr & 0x00ff0000) >> 16,
-				(bi->ipaddr & 0x0000ff00) >> 8,
-				(bi->ipaddr & 0x000000ff));
+		sprintf(tstr, "%u.%u.%u.%u",
+			0xFF & ((bi->ipaddr & 0xff000000) >> 24),
+			0xFF & ((bi->ipaddr & 0x00ff0000) >> 16),
+			0xFF & ((bi->ipaddr & 0x0000ff00) >> 8),
+			0xFF & ((bi->ipaddr & 0x000000ff)));
 		purple_notify_user_info_add_pair_plaintext(user_info, _("IP Address"), tstr);
 	}
 	oscar_user_info_convert_and_add(account, od, user_info, _("First Name"), info->first);
--- a/libpurple/util.c	Fri Oct 04 12:58:15 2013 +0200
+++ b/libpurple/util.c	Fri Oct 04 17:46:37 2013 +0200
@@ -166,7 +166,7 @@
 	ascii = g_malloc(len * 2 + 1);
 
 	for (i = 0; i < len; i++)
-		g_snprintf(&ascii[i * 2], 3, "%02hx", data[i] & 0xFF);
+		g_snprintf(&ascii[i * 2], 3, "%02x", data[i] & 0xFF);
 
 	return ascii;
 }
@@ -234,7 +234,7 @@
 	ascii = g_malloc(len * 3 + 1);
 
 	for (i = 0; i < len; i++)
-		g_snprintf(&ascii[i * 3], 4, "%02hx:", data[i] & 0xFF);
+		g_snprintf(&ascii[i * 3], 4, "%02x:", data[i] & 0xFF);
 
 	/* Replace the final colon with NULL */
 	ascii[len * 3 - 1] = 0;
@@ -3756,7 +3756,7 @@
 
 	for (i = 0; i < len; i++)
 		if (binary[i] < 32 || binary[i] > 126)
-			g_string_append_printf(ret, "\\x%02hx", binary[i] & 0xFF);
+			g_string_append_printf(ret, "\\x%02x", binary[i] & 0xFF);
 		else if (binary[i] == '\\')
 			g_string_append(ret, "\\\\");
 		else

mercurial