/pidgin/main: 3d727b2e6f82: Fix most of libpurple clang scan-bui...

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu Apr 3 12:01:19 EDT 2014


Changeset: 3d727b2e6f82734df7f02f560d299fba3e99eacf
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-03 18:01 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/3d727b2e6f82

Description:

Fix most of libpurple clang scan-build warnings

diffstat:

 libpurple/memorypool.c                     |  4 ++++
 libpurple/protocols/irc/msgs.c             |  4 ++--
 libpurple/protocols/jabber/caps.c          |  7 +++++++
 libpurple/protocols/msn/contact.c          |  1 -
 libpurple/protocols/msn/msn.c              |  3 +++
 libpurple/protocols/msn/p2p.c              |  4 ++++
 libpurple/protocols/mxit/chunk.c           |  6 ++++++
 libpurple/protocols/oscar/family_feedbag.c |  6 ++++++
 libpurple/protocols/yahoo/yahoo_profile.c  |  6 ++++--
 9 files changed, 36 insertions(+), 5 deletions(-)

diffs (197 lines):

diff --git a/libpurple/memorypool.c b/libpurple/memorypool.c
--- a/libpurple/memorypool.c
+++ b/libpurple/memorypool.c
@@ -128,6 +128,9 @@ purple_memory_pool_alloc_impl(PurpleMemo
 		blk = purple_memory_pool_block_new(real_size);
 		g_return_val_if_fail(blk != NULL, NULL);
 
+		g_assert((priv->first_block == NULL) ==
+			(priv->last_block == NULL));
+
 		if (priv->first_block == NULL) {
 			priv->first_block = blk;
 			priv->last_block = blk;
@@ -160,6 +163,7 @@ purple_memory_pool_cleanup_impl(PurpleMe
 
 	blk = priv->first_block;
 	priv->first_block = NULL;
+	priv->last_block = NULL;
 	while (blk) {
 		PurpleMemoryPoolBlock *next = blk->next;
 		g_free(blk);
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -1466,7 +1466,6 @@ irc_auth_start_cyrus(struct irc_conn *ir
 	PurpleAccount *account = irc->account;
 	PurpleConnection *gc = purple_account_get_connection(account);
 
-	gboolean plaintext;
 	gboolean again = FALSE;
 
 	/* Set up security properties and options */
@@ -1474,6 +1473,8 @@ irc_auth_start_cyrus(struct irc_conn *ir
 	secprops.security_flags = SASL_SEC_NOANONYMOUS;
 
 	if (!irc->gsc) {
+		gboolean plaintext;
+
 		secprops.max_ssf = -1;
 		secprops.maxbufsize = 4096;
 		plaintext = purple_account_get_bool(account, "auth_plain_in_clear", FALSE);
@@ -1482,7 +1483,6 @@ irc_auth_start_cyrus(struct irc_conn *ir
 	} else {
 		secprops.max_ssf = 0;
 		secprops.maxbufsize = 0;
-		plaintext = TRUE;
 	}
 
 	secprops.property_names = 0;
diff --git a/libpurple/protocols/jabber/caps.c b/libpurple/protocols/jabber/caps.c
--- a/libpurple/protocols/jabber/caps.c
+++ b/libpurple/protocols/jabber/caps.c
@@ -505,6 +505,13 @@ jabber_caps_client_iqcb(JabberStream *js
 		info = value;
 	} else {
 		JabberCapsTuple *n_key = (JabberCapsTuple *)&info->tuple;
+
+		if (G_UNLIKELY(n_key == NULL)) {
+			g_warn_if_reached();
+			jabber_caps_client_info_destroy(info);
+			return;
+		}
+
 		n_key->node = userdata->node;
 		n_key->ver  = userdata->ver;
 		n_key->hash = userdata->hash;
diff --git a/libpurple/protocols/msn/contact.c b/libpurple/protocols/msn/contact.c
--- a/libpurple/protocols/msn/contact.c
+++ b/libpurple/protocols/msn/contact.c
@@ -698,7 +698,6 @@ msn_parse_addressbook_contacts(MsnSessio
 		g_free(mobile_number);
 		g_free(alias);
 		passport = Name = uid = type = mobile_number = alias = NULL;
-		mobile = FALSE;
 
 		if (!(contactId = purple_xmlnode_get_child(contactNode,"contactId"))
 				|| !(contactInfo = purple_xmlnode_get_child(contactNode, "contactInfo"))
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -2536,7 +2536,10 @@ msn_got_info(PurpleHttpConnection *http_
 	{
 		has_info = TRUE;
 		sect_info = FALSE;
+#if 0
+		/* it's true, but we don't need this assignment */
 		has_contact_info = TRUE;
+#endif
 	}
     else
     {
diff --git a/libpurple/protocols/msn/p2p.c b/libpurple/protocols/msn/p2p.c
--- a/libpurple/protocols/msn/p2p.c
+++ b/libpurple/protocols/msn/p2p.c
@@ -161,7 +161,9 @@ msn_p2p_header_from_wire(MsnP2PInfo *inf
 
 				if (header->data_header_len > 8) {
 					header->data_tlv = msn_tlvlist_read(wire, header->data_header_len - 8);
+#if 0
 					wire += header->data_header_len - 8;
+#endif
 				}
 			}
 
@@ -238,7 +240,9 @@ msn_p2p_header_to_wire(MsnP2PInfo *info,
 
 			if (data_header_wire != NULL) {
 				memcpy(tmp, data_header_wire, header->data_header_len);
+#if 0
 				tmp += header->data_header_len;
+#endif
 			}
 
 			if (len)
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
@@ -480,6 +480,9 @@ void mxit_chunk_parse_offer( char* chunk
 	/* mime type [UTF-8] */
 	pos += get_utf8_string( &chunkdata[pos], offer->mimetype, sizeof( offer->mimetype ) );
 
+	if (pos > datalen)
+		purple_debug_warning(MXIT_PLUGIN_ID, "pos > datalen");
+
 	/* timestamp [8 bytes] */
 	/* not used by libPurple */
 
@@ -643,6 +646,9 @@ void mxit_chunk_parse_sendfile( char* ch
 
 	/* status message [UTF-8 string] */
 	pos += get_utf8_string( &chunkdata[pos], sendfile->statusmsg, sizeof( sendfile->statusmsg ) );
+
+	if (pos != datalen)
+		purple_debug_misc(MXIT_PLUGIN_ID, "pos != datalen");
 }
 
 
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
@@ -1755,6 +1755,8 @@ static int receiveauthgrant(OscarData *o
 
 	/* Unknown */
 	tmp = byte_stream_get16(bs);
+	if (!tmp)
+		purple_debug_warning("oscar", "unknown field missing");
 
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, bn, msg);
@@ -1846,6 +1848,8 @@ static int receiveauthrequest(OscarData 
 
 	/* Unknown */
 	tmp = byte_stream_get16(bs);
+	if (!tmp)
+		purple_debug_warning("oscar", "unknown field missing");
 
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, bn, msg);
@@ -1950,6 +1954,8 @@ static int receiveauthreply(OscarData *o
 
 	/* Unknown */
 	tmp = byte_stream_get16(bs);
+	if (!tmp)
+		purple_debug_warning("oscar", "unknown field missing");
 
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, bn, reply, msg);
diff --git a/libpurple/protocols/yahoo/yahoo_profile.c b/libpurple/protocols/yahoo/yahoo_profile.c
--- a/libpurple/protocols/yahoo/yahoo_profile.c
+++ b/libpurple/protocols/yahoo/yahoo_profile.c
@@ -978,6 +978,8 @@ yahoo_got_photo(PurpleHttpConnection *ht
 	/* in to purple_markup_strip_html*/
 	char *fudged_buffer;
 
+	g_return_if_fail(strings != NULL);
+
 	yd = purple_connection_get_protocol_data(info_data->gc);
 
 	fudged_buffer = purple_strcasereplace(url_buffer, "</dd>", "</dd><br>");
@@ -989,7 +991,7 @@ yahoo_got_photo(PurpleHttpConnection *ht
 	purple_debug_misc("yahoo", "url_buffer = %p\n", url_buffer);
 
 	/* convert to utf8 */
-	if (strings && strings->charset) {
+	if (strings->charset) {
 		p = g_convert(stripped, -1, "utf-8", strings->charset,
 				NULL, NULL, NULL);
 		if (!p) {
@@ -1009,7 +1011,7 @@ yahoo_got_photo(PurpleHttpConnection *ht
 	p = NULL;
 
 	/* "Last updated" should also be converted to utf8 and with   killed */
-	if (strings && strings->charset) {
+	if (strings->charset) {
 		last_updated_utf8_string = g_convert(last_updated_string, -1, "utf-8",
 				strings->charset, NULL, NULL, NULL);
 		yahoo_remove_nonbreaking_spaces(last_updated_utf8_string);



More information about the Commits mailing list