/pidgin/main: 5061721fd98f: Remove more NULL-checks before free()

Michael McConville mmcco at mykolab.com
Mon Dec 21 15:00:50 EST 2015


Changeset: 5061721fd98fe82ad7f8d77c5096249b37eae475
Author:	 Michael McConville <mmcco at mykolab.com>
Date:	 2015-12-21 15:00 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/5061721fd98f

Description:

Remove more NULL-checks before free()

diffstat:

 libpurple/protocols/novell/nmconference.c |   3 +-
 libpurple/protocols/novell/nmconn.c       |   6 +-
 libpurple/protocols/novell/nmcontact.c    |  24 +++-------
 libpurple/protocols/novell/nmevent.c      |  51 +++++++-----------------
 libpurple/protocols/novell/nmmessage.c    |   3 +-
 libpurple/protocols/novell/nmrequest.c    |   3 +-
 libpurple/protocols/novell/nmuserrecord.c |  63 ++++++++++--------------------
 libpurple/protocols/novell/novell.c       |  27 ++++--------
 8 files changed, 59 insertions(+), 121 deletions(-)

diffs (truncated from 501 to 300 lines):

diff --git a/libpurple/protocols/novell/nmconference.c b/libpurple/protocols/novell/nmconference.c
--- a/libpurple/protocols/novell/nmconference.c
+++ b/libpurple/protocols/novell/nmconference.c
@@ -83,8 +83,7 @@ nm_release_conference(NMConference * con
 				   "Releasing conference %p, total=%d\n",
 				   conference, --conf_count);
 
-		if (conference->guid)
-			g_free(conference->guid);
+		g_free(conference->guid);
 
 		if (conference->participants) {
 			for (node = conference->participants; node; node = node->next) {
diff --git a/libpurple/protocols/novell/nmconn.c b/libpurple/protocols/novell/nmconn.c
--- a/libpurple/protocols/novell/nmconn.c
+++ b/libpurple/protocols/novell/nmconn.c
@@ -187,10 +187,8 @@ void nm_release_conn(NMConn *conn)
 		}
 		g_slist_free(conn->requests);
 		conn->requests = NULL;
-		if (conn->ssl_conn) {
-			g_free(conn->ssl_conn);
-			conn->ssl_conn = NULL;
-		}
+		g_free(conn->ssl_conn);
+		conn->ssl_conn = NULL;
 		g_free(conn->addr);
 		conn->addr = NULL;
 		g_free(conn);
diff --git a/libpurple/protocols/novell/nmcontact.c b/libpurple/protocols/novell/nmcontact.c
--- a/libpurple/protocols/novell/nmcontact.c
+++ b/libpurple/protocols/novell/nmcontact.c
@@ -164,8 +164,7 @@ nm_contact_update_list_properties(NMCont
 		 nm_locate_field(NM_A_SZ_DISPLAY_NAME, (NMField *) fields->ptr_value))) {
 
 		if (field->ptr_value) {
-			if (contact->display_name)
-				g_free(contact->display_name);
+			g_free(contact->display_name);
 
 			contact->display_name = g_strdup((char *) field->ptr_value);
 		}
@@ -175,8 +174,7 @@ nm_contact_update_list_properties(NMCont
 	if ((field = nm_locate_field(NM_A_SZ_DN, (NMField *) fields->ptr_value))) {
 
 		if (field->ptr_value) {
-			if (contact->dn)
-				g_free(contact->dn);
+			g_free(contact->dn);
 
 			contact->dn = g_strdup((char *) field->ptr_value);
 		}
@@ -303,10 +301,8 @@ nm_contact_set_display_name(NMContact * 
 	if (contact == NULL)
 		return;
 
-	if (contact->display_name) {
-		g_free(contact->display_name);
-		contact->display_name = NULL;
-	}
+	g_free(contact->display_name);
+	contact->display_name = NULL;
 
 	if (display_name)
 		contact->display_name = g_strdup(display_name);
@@ -318,10 +314,8 @@ nm_contact_set_dn(NMContact * contact, c
 	if (contact == NULL)
 		return;
 
-	if (contact->dn) {
-		g_free(contact->dn);
-		contact->dn = NULL;
-	}
+	g_free(contact->dn);
+	contact->dn = NULL;
 
 	if (dn)
 		contact->dn = g_strdup(dn);
@@ -538,8 +532,7 @@ nm_folder_update_list_properties(NMFolde
 		 nm_locate_field(NM_A_SZ_DISPLAY_NAME, (NMField *) fields->ptr_value))) {
 
 		if (field->ptr_value) {
-			if (folder->name)
-				g_free(folder->name);
+			g_free(folder->name);
 
 			folder->name = g_strdup((char *) field->ptr_value);
 		}
@@ -640,8 +633,7 @@ nm_folder_set_name(NMFolder * folder, co
 	if (folder == NULL || name == NULL)
 		return;
 
-	if (folder->name)
-		g_free(folder->name);
+	g_free(folder->name);
 
 	folder->name = g_strdup(name);
 }
diff --git a/libpurple/protocols/novell/nmevent.c b/libpurple/protocols/novell/nmevent.c
--- a/libpurple/protocols/novell/nmevent.c
+++ b/libpurple/protocols/novell/nmevent.c
@@ -241,14 +241,9 @@ handle_receive_message(NMUser * user, NM
 		nm_release_conference(conference);
 	}
 
-	if (msg)
-		g_free(msg);
-
-	if (nortf)
-		g_free(nortf);
-
-	if (guid)
-		g_free(guid);
+	g_free(msg);
+	g_free(nortf);
+	g_free(guid);
 
 	return rc;
 }
@@ -323,11 +318,8 @@ handle_conference_invite(NMUser * user, 
 		}
 	}
 
-	if (msg)
-		g_free(msg);
-
-	if (guid)
-		g_free(guid);
+	g_free(msg);
+	g_free(guid);
 
 	return rc;
 }
@@ -381,8 +373,7 @@ handle_conference_invite_notify(NMUser *
 	}
 
 
-	if (guid)
-		g_free(guid);
+	g_free(guid);
 
 	return rc;
 }
@@ -417,8 +408,7 @@ handle_conference_reject(NMUser * user, 
 		}
 	}
 
-	if (guid)
-		g_free(guid);
+	g_free(guid);
 
 	return rc;
 }
@@ -468,8 +458,7 @@ handle_conference_left(NMUser * user, NM
 		}
 	}
 
-	if (guid)
-		g_free(guid);
+	g_free(guid);
 
 	return rc;
 }
@@ -507,8 +496,7 @@ handle_conference_closed(NMUser * user, 
 		}
 	}
 
-	if (guid)
-		g_free(guid);
+	g_free(guid);
 
 	return rc;
 }
@@ -569,8 +557,7 @@ handle_conference_joined(NMUser * user, 
 		}
 	}
 
-	if (guid)
-		g_free(guid);
+	g_free(guid);
 
 	return rc;
 }
@@ -605,8 +592,7 @@ handle_typing(NMUser * user, NMEvent * e
 		}
 	}
 
-	if (guid)
-		g_free(guid);
+	g_free(guid);
 
 	return rc;
 }
@@ -651,8 +637,7 @@ handle_status_change(NMUser * user, NMEv
 		}
 	}
 
-	if (text)
-		g_free(text);
+	g_free(text);
 
 	return rc;
 }
@@ -677,8 +662,7 @@ handle_undeliverable_status(NMUser * use
 		rc = nm_read_all(conn, guid, size);
 	}
 
-	if (guid)
-		g_free(guid);
+	g_free(guid);
 
 	return rc;
 }
@@ -712,8 +696,7 @@ nm_release_event(NMEvent * event)
 
 	if (--(event->ref_count) == 0) {
 
-		if (event->source)
-			g_free(event->source);
+		g_free(event->source);
 
 		if (event->conference)
 			nm_release_conference(event->conference);
@@ -721,8 +704,7 @@ nm_release_event(NMEvent * event)
 		if (event->user_record)
 			nm_release_user_record(event->user_record);
 
-		if (event->text)
-			g_free(event->text);
+		g_free(event->text);
 
 		g_free(event);
 	}
@@ -936,8 +918,7 @@ nm_process_event(NMUser * user, int type
 	}
 
 	/* Cleanup */
-	if (source)
-		g_free(source);
+	g_free(source);
 
 	return rc;
 }
diff --git a/libpurple/protocols/novell/nmmessage.c b/libpurple/protocols/novell/nmmessage.c
--- a/libpurple/protocols/novell/nmmessage.c
+++ b/libpurple/protocols/novell/nmmessage.c
@@ -53,8 +53,7 @@ void
 nm_release_message(NMMessage * msg)
 {
 	if (msg && (--(msg->ref_count) == 0)) {
-		if (msg->text)
-			g_free(msg->text);
+		g_free(msg->text);
 
 		if (msg->conference)
 			nm_release_conference(msg->conference);
diff --git a/libpurple/protocols/novell/nmrequest.c b/libpurple/protocols/novell/nmrequest.c
--- a/libpurple/protocols/novell/nmrequest.c
+++ b/libpurple/protocols/novell/nmrequest.c
@@ -60,8 +60,7 @@ void
 nm_release_request(NMRequest * req)
 {
 	if (req && (--req->ref_count == 0)) {
-		if (req->cmd)
-			g_free(req->cmd);
+		g_free(req->cmd);
 		g_free(req);
 
 		purple_debug_info("novell",
diff --git a/libpurple/protocols/novell/nmuserrecord.c b/libpurple/protocols/novell/nmuserrecord.c
--- a/libpurple/protocols/novell/nmuserrecord.c
+++ b/libpurple/protocols/novell/nmuserrecord.c
@@ -191,64 +191,50 @@ nm_user_record_copy(NMUserRecord * dest,
 	dest->status = src->status;
 
 	/* Copy status text */
-	if (dest->status_text) {
-		g_free(dest->status_text);
-		dest->status_text = NULL;
-	}
+	g_free(dest->status_text);
+	dest->status_text = NULL;
 
 	if (src->status_text)
 		dest->status_text = g_strdup(src->status_text);
 
 	/* Copy DN */
-	if (dest->dn) {
-		g_free(dest->dn);
-		dest->dn = NULL;
-	}
+	g_free(dest->dn);
+	dest->dn = NULL;
 
 	if (src->dn)
 		dest->dn = g_strdup(src->dn);
 
 	/* Copy CN */
-	if (dest->cn) {
-		g_free(dest->cn);



More information about the Commits mailing list