=?UTF-8?Q?Fr=C3=A9d=C3=A9ric=20Delanoy=20?=: inetmib1: Avoid idempotent operation in findSupportedQuery function (Clang).

Alexandre Julliard julliard at winehq.org
Fri Oct 14 14:14:49 CDT 2011


Module: wine
Branch: master
Commit: 699fb02d101d708b52cd8904f82ab455c9b00a4e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=699fb02d101d708b52cd8904f82ab455c9b00a4e

Author: Frédéric Delanoy <frederic.delanoy at gmail.com>
Date:   Fri Oct 14 13:02:35 2011 +0200

inetmib1: Avoid idempotent operation in findSupportedQuery function (Clang).

---

 dlls/inetmib1/main.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c
index 76741f3..af9f17c 100644
--- a/dlls/inetmib1/main.c
+++ b/dlls/inetmib1/main.c
@@ -1342,29 +1342,26 @@ static void cleanup(void)
 static struct mibImplementation *findSupportedQuery(UINT *ids, UINT idLength,
     UINT *matchingIndex)
 {
-    int indexHigh = DEFINE_SIZEOF(supportedIDs) - 1, indexLow = 0, i;
-    struct mibImplementation *impl = NULL;
+    int indexHigh = DEFINE_SIZEOF(supportedIDs) - 1, indexLow = 0;
     AsnObjectIdentifier oid1 = { idLength, ids};
 
     if (!idLength)
         return NULL;
-    for (i = (indexLow + indexHigh) / 2; !impl && indexLow <= indexHigh;
-         i = (indexLow + indexHigh) / 2)
-    {
-        INT cmp;
 
-        cmp = SnmpUtilOidNCmp(&oid1, &supportedIDs[i].name, idLength);
-        if (!cmp)
+    while (indexLow <= indexHigh)
+    {
+        INT cmp, i = (indexLow + indexHigh) / 2;
+        if (!(cmp = SnmpUtilOidNCmp(&oid1, &supportedIDs[i].name, idLength)))
         {
-            impl = &supportedIDs[i];
             *matchingIndex = i;
+            return &supportedIDs[i];
         }
-        else if (cmp > 0)
+        if (cmp > 0)
             indexLow = i + 1;
         else
             indexHigh = i - 1;
     }
-    return impl;
+    return NULL;
 }
 
 /*****************************************************************************




More information about the wine-cvs mailing list