[PATCH libICE 03/13] save one indentlevel in IceProtocolSetup

walter harms wharms at bfs.de
Wed Oct 18 15:53:02 UTC 2017



save one indentlevel in IceProtocolSetup by early check and
remove a lost free() check
Signed-off-by: Walter Harms <wharms at bfs.de>

---
 src/protosetup.c | 61 +++++++++++++++++++++++++++-----------------------------
 1 file changed, 29 insertions(+), 32 deletions(-)

diff --git a/src/protosetup.c b/src/protosetup.c
index fc6010a..b6aece8 100644
--- a/src/protosetup.c
+++ b/src/protosetup.c
@@ -60,6 +60,7 @@ IceProtocolSetup (
     IcePoVersionRec	*versionRec = NULL;
     int			authCount;
     int			*authIndices;
+    _IceProcessMsgInfo  *process_msg_info;

     if (errorStringRet && errorLength > 0)
 	*errorStringRet = '\0';
@@ -235,53 +236,49 @@ IceProtocolSetup (
 		free (reply.protocol_error.error_message);
 	    }

-	    if (iceConn->protosetup_to_you->my_auth_indices)
-		free (iceConn->protosetup_to_you->my_auth_indices);
+
+	    free (iceConn->protosetup_to_you->my_auth_indices);
 	    free (iceConn->protosetup_to_you);
 	    iceConn->protosetup_to_you = NULL;
 	}
     }

-    if (accepted)
-    {
-	_IceProcessMsgInfo *process_msg_info;
+    if (!accepted)
+	return (IceProtocolSetupFailure);

-	*majorVersionRet = versionRec->major_version;
-	*minorVersionRet = versionRec->minor_version;
-	*vendorRet = reply.protocol_reply.vendor;
-	*releaseRet = reply.protocol_reply.release;
+    *majorVersionRet = versionRec->major_version;
+    *minorVersionRet = versionRec->minor_version;
+    *vendorRet = reply.protocol_reply.vendor;
+    *releaseRet = reply.protocol_reply.release;


-	/*
-	 * Increase the reference count for the number of active protocols.
-	 */
+    /*
+     * Increase the reference count for the number of active protocols.
+     */

-	iceConn->proto_ref_count++;
+    iceConn->proto_ref_count++;


-	/*
-	 * We may be using a different major opcode for this protocol
-	 * than the other client.  Whenever we get a message, we must
-	 * map to our own major opcode.
-	 */
+    /*
+     * We may be using a different major opcode for this protocol
+     * than the other client.  Whenever we get a message, we must
+     * map to our own major opcode.
+     */

-	hisOpcode = reply.protocol_reply.major_opcode;
+    hisOpcode = reply.protocol_reply.major_opcode;

-	_IceAddOpcodeMapping (iceConn, hisOpcode, myOpcode);
+    _IceAddOpcodeMapping (iceConn, hisOpcode, myOpcode);

-	process_msg_info = &iceConn->process_msg_info[hisOpcode -
-	    iceConn->his_min_opcode];
+    process_msg_info = &iceConn->process_msg_info[hisOpcode -
+						  iceConn->his_min_opcode];

-	process_msg_info->client_data = clientData;
-	process_msg_info->accept_flag = 0;
+    process_msg_info->client_data = clientData;
+    process_msg_info->accept_flag = 0;

-	process_msg_info->process_msg_proc.orig_client =
-		versionRec->process_msg_proc;
+    process_msg_info->process_msg_proc.orig_client =
+      versionRec->process_msg_proc;
+
+    return (IceProtocolSetupSuccess);
+

-	return (IceProtocolSetupSuccess);
-    }
-    else
-    {
-	return (IceProtocolSetupFailure);
-    }
 }
-- 
2.1.4



More information about the xorg-devel mailing list