[PATCH libICE 02/13] make IceProtocolShutdown() more readable

walter harms wharms at bfs.de
Wed Oct 18 15:55:56 UTC 2017


 make IceProtocolShutdown() more readable

 Signed-off-by: Walter Harms <wharms at bfs.de>

---
 src/shutdown.c | 47 ++++++++++++++++++++---------------------------
 1 file changed, 20 insertions(+), 27 deletions(-)

diff --git a/src/shutdown.c b/src/shutdown.c
index 90e9ded..98376a7 100644
--- a/src/shutdown.c
+++ b/src/shutdown.c
@@ -40,45 +40,38 @@ IceProtocolShutdown (
 	int	majorOpcode
 )
 {
+    int i;
+
     if (iceConn->proto_ref_count == 0 || iceConn->process_msg_info == NULL ||
         majorOpcode < 1 || majorOpcode > _IceLastMajorOpcode)
     {
 	return (0);
     }
-    else
-    {
-	/*
-	 * Make sure this majorOpcode is really being used.
-	 */
-
-	int i;
+
+
+    /*
+     * Make sure this majorOpcode is really being used.
+     */

-	for (i = iceConn->his_min_opcode; i <= iceConn->his_max_opcode; i++)
-	{
-	    if (iceConn->process_msg_info[
-		i - iceConn->his_min_opcode].in_use &&
-                iceConn->process_msg_info[
-		i - iceConn->his_min_opcode].my_opcode == majorOpcode)
-		break;
-	}
+    for (i = iceConn->his_min_opcode; i <= iceConn->his_max_opcode; i++)
+      {
+	int n=i - iceConn->his_min_opcode;
+	if (iceConn->process_msg_info[n].in_use &&
+	    iceConn->process_msg_info[n].my_opcode == majorOpcode)
+	  {

-	if (i > iceConn->his_max_opcode)
-	{
-	    return (0);
-	}
-	else
-	{
 	    /*
 	     * OK, we can shut down the protocol.
 	     */

-	    iceConn->process_msg_info[
-		i - iceConn->his_min_opcode].in_use = False;
-	    iceConn->proto_ref_count--;
+	      iceConn->process_msg_info[n].in_use = False;
+	      iceConn->proto_ref_count--;
+	      return (1);
+	  }
+				
+      }

-	    return (1);
-	}
-    }
+    return (0);
 }


-- 
2.1.4



More information about the xorg-devel mailing list