/pidgin/main: d2f0259aa43f: Remove NULL-checks before free(). No...

Michael McConville mmcco at mykolab.com
Mon Dec 21 14:46:20 EST 2015


Changeset: d2f0259aa43f89acf8d972f32c0bc9e448a5411b
Author:	 Michael McConville <mmcco at mykolab.com>
Date:	 2015-12-21 14:46 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/d2f0259aa43f

Description:

Remove NULL-checks before free(). No functional change.

diffstat:

 libpurple/protocols/jabber/chat.c              |   9 +++------
 libpurple/protocols/jabber/disco.c             |   3 +--
 libpurple/protocols/jabber/google/jingleinfo.c |   3 +--
 libpurple/protocols/jabber/ibb.c               |   6 ++----
 libpurple/protocols/jabber/jabber.c            |  12 ++++--------
 libpurple/protocols/jabber/message.c           |   3 +--
 libpurple/protocols/jabber/presence.c          |  14 +++++---------
 libpurple/protocols/jabber/si.c                |   3 +--
 8 files changed, 18 insertions(+), 35 deletions(-)

diffs (168 lines):

diff --git a/libpurple/protocols/jabber/chat.c b/libpurple/protocols/jabber/chat.c
--- a/libpurple/protocols/jabber/chat.c
+++ b/libpurple/protocols/jabber/chat.c
@@ -540,8 +540,7 @@ static void jabber_chat_room_configure_c
 			_("Configuration error"), msg,
 			purple_request_cpar_from_connection(js->gc));
 
-		if(msg)
-			g_free(msg);
+		g_free(msg);
 		return;
 	}
 
@@ -621,8 +620,7 @@ jabber_chat_register_x_data_result_cb(Ja
 			_("Registration error"), msg,
 			purple_request_cpar_from_connection(js->gc));
 
-		if(msg)
-			g_free(msg);
+		g_free(msg);
 		return;
 	}
 }
@@ -692,8 +690,7 @@ static void jabber_chat_register_cb(Jabb
 			_("Registration error"), msg,
 			purple_request_cpar_from_connection(js->gc));
 
-		if(msg)
-			g_free(msg);
+		g_free(msg);
 		return;
 	}
 
diff --git a/libpurple/protocols/jabber/disco.c b/libpurple/protocols/jabber/disco.c
--- a/libpurple/protocols/jabber/disco.c
+++ b/libpurple/protocols/jabber/disco.c
@@ -452,8 +452,7 @@ jabber_disco_stun_lookup_cb(GSList *host
 			port = ntohs(addr.in.sin_port);
 		}
 
-		if (js->stun_ip)
-			g_free(js->stun_ip);
+		g_free(js->stun_ip);
 		js->stun_ip = g_strdup(dst);
 		js->stun_port = port;
 
diff --git a/libpurple/protocols/jabber/google/jingleinfo.c b/libpurple/protocols/jabber/google/jingleinfo.c
--- a/libpurple/protocols/jabber/google/jingleinfo.c
+++ b/libpurple/protocols/jabber/google/jingleinfo.c
@@ -53,8 +53,7 @@ jabber_google_stun_lookup_cb(GSList *hos
 			port = ntohs(addr.in.sin_port);
 		}
 
-		if (js->stun_ip)
-			g_free(js->stun_ip);
+		g_free(js->stun_ip);
 		js->stun_ip = g_strdup(dst);
 		js->stun_port = port;
 
diff --git a/libpurple/protocols/jabber/ibb.c b/libpurple/protocols/jabber/ibb.c
--- a/libpurple/protocols/jabber/ibb.c
+++ b/libpurple/protocols/jabber/ibb.c
@@ -294,10 +294,8 @@ jabber_ibb_session_send_acknowledge_cb(J
 
 	if (sess) {
 		/* reset callback */
-		if (sess->last_iq_id) {
-			g_free(sess->last_iq_id);
-			sess->last_iq_id = NULL;
-		}
+		g_free(sess->last_iq_id);
+		sess->last_iq_id = NULL;
 
 		if (type == JABBER_IQ_ERROR) {
 			jabber_ibb_session_close(sess);
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -101,10 +101,8 @@ static void jabber_stream_init(JabberStr
 {
 	char *open_stream;
 
-	if (js->stream_id) {
-		g_free(js->stream_id);
-		js->stream_id = NULL;
-	}
+	g_free(js->stream_id);
+	js->stream_id = NULL;
 
 	open_stream = g_strdup_printf("<stream:stream to='%s' "
 				          "xmlns='" NS_XMPP_CLIENT "' "
@@ -2638,10 +2636,8 @@ void jabber_convo_closed(PurpleConnectio
 
 	if((jb = jabber_buddy_find(js, who, TRUE)) &&
 			(jbr = jabber_buddy_find_resource(jb, jid->resource))) {
-		if(jbr->thread_id) {
-			g_free(jbr->thread_id);
-			jbr->thread_id = NULL;
-		}
+		g_free(jbr->thread_id);
+		jbr->thread_id = NULL;
 	}
 
 	jabber_id_free(jid);
diff --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -147,8 +147,7 @@ static void handle_chat(JabberMessage *j
 					jbr->chat_states = JABBER_CHAT_STATES_UNSUPPORTED;
 			}
 
-			if(jbr->thread_id)
-				g_free(jbr->thread_id);
+			g_free(jbr->thread_id);
 			jbr->thread_id = g_strdup(jbr->thread_id);
 		}
 
diff --git a/libpurple/protocols/jabber/presence.c b/libpurple/protocols/jabber/presence.c
--- a/libpurple/protocols/jabber/presence.c
+++ b/libpurple/protocols/jabber/presence.c
@@ -245,10 +245,8 @@ void jabber_presence_send(JabberStream *
 
 		/* update old values */
 
-		if(js->old_msg)
-			g_free(js->old_msg);
-		if(js->old_avatarhash)
-			g_free(js->old_avatarhash);
+		g_free(js->old_msg);
+		g_free(js->old_avatarhash);
 		js->old_msg = g_strdup(stripped);
 		js->old_avatarhash = g_strdup(js->avatar_hash);
 		js->old_state = state;
@@ -440,7 +438,7 @@ jabber_vcard_parse_avatar(JabberStream *
 			if (tmp && strstr(bare_jid, tmp) == NULL) {
 				g_free(nickname);
 				nickname = tmp;
-			} else if (tmp)
+			} else
 				g_free(tmp);
 
 			g_free(bare_jid);
@@ -945,10 +943,8 @@ void jabber_presence_parse(JabberStream 
 	if (presence.jid_from->node)
 		presence.chat = jabber_chat_find(js, presence.jid_from->node,
 		                                 presence.jid_from->domain);
-	if(presence.jb->error_msg) {
-		g_free(presence.jb->error_msg);
-		presence.jb->error_msg = NULL;
-	}
+	g_free(presence.jb->error_msg);
+	presence.jb->error_msg = NULL;
 
 	if (presence.type == JABBER_PRESENCE_AVAILABLE) {
 		presence.state = JABBER_BUDDY_STATE_ONLINE;
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
@@ -351,8 +351,7 @@ void jabber_bytestreams_parse(JabberStre
 	if(!jsx->accepted)
 		return;
 
-	if(jsx->iq_id)
-		g_free(jsx->iq_id);
+	g_free(jsx->iq_id);
 	jsx->iq_id = g_strdup(id);
 
 	for(streamhost = purple_xmlnode_get_child(query, "streamhost"); streamhost;



More information about the Commits mailing list