/pidgin/main: c3077dd1c5c7: Move g_return_if_fail to top of func...

Mark Doliner mark at kingant.net
Tue Jan 28 10:38:13 EST 2014


Changeset: c3077dd1c5c7d5468b5f3279e50f2e76a252c756
Author:	 Mark Doliner <mark at kingant.net>
Date:	 2014-01-19 20:26 -0800
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/c3077dd1c5c7

Description:

Move g_return_if_fail to top of function and exit early.

This way the meat of the function isn't needlessly indented.
I think it's easier to read code structured this way.

diffstat:

 libpurple/protocols/jabber/bosh.c |  22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diffs (39 lines):

diff --git a/libpurple/protocols/jabber/bosh.c b/libpurple/protocols/jabber/bosh.c
--- a/libpurple/protocols/jabber/bosh.c
+++ b/libpurple/protocols/jabber/bosh.c
@@ -623,24 +623,24 @@ static void jabber_bosh_connection_boot(
 static void
 http_received_cb(const char *data, int len, PurpleBOSHConnection *conn)
 {
+	xmlnode *node;
+
 	if (conn->failed_connections)
 		/* We've got some data, so reset the number of failed connections */
 		conn->failed_connections = 0;
 
-	if (conn->receive_cb) {
-		xmlnode *node = xmlnode_from_str(data, len);
+	g_return_if_fail(conn->receive_cb);
 
-		purple_debug_info("jabber", "RecvBOSH %s(%d): %s\n",
-		                  conn->ssl ? "(ssl)" : "", len, data);
+	node = xmlnode_from_str(data, len);
 
-		if (node) {
-			conn->receive_cb(conn, node);
-			xmlnode_free(node);
-		} else {
-			purple_debug_warning("jabber", "BOSH: Received invalid XML\n");
-		}
+	purple_debug_info("jabber", "RecvBOSH %s(%d): %s\n",
+	                  conn->ssl ? "(ssl)" : "", len, data);
+
+	if (node) {
+		conn->receive_cb(conn, node);
+		xmlnode_free(node);
 	} else {
-		g_return_if_reached();
+		purple_debug_warning("jabber", "BOSH: Received invalid XML\n");
 	}
 }
 



More information about the Commits mailing list