inetmib1: Avoid idempotent operation in findSupportedQuery function (Clang) (try 2)

Frédéric Delanoy frederic.delanoy at gmail.com
Mon Oct 10 18:59:19 CDT 2011


indexLow is always 0 at that point

try 2: restructured and simplified loop
---
 dlls/inetmib1/main.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c
index 76741f3..7a23817 100644
--- a/dlls/inetmib1/main.c
+++ b/dlls/inetmib1/main.c
@@ -1343,28 +1343,28 @@ static struct mibImplementation *findSupportedQuery(UINT *ids, UINT idLength,
     UINT *matchingIndex)
 {
     int indexHigh = DEFINE_SIZEOF(supportedIDs) - 1, indexLow = 0, i;
-    struct mibImplementation *impl = NULL;
     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);
+    i = indexHigh / 2;
+    while (indexLow <= indexHigh)
+    {
+        INT cmp = SnmpUtilOidNCmp(&oid1, &supportedIDs[i].name, idLength);
         if (!cmp)
         {
-            impl = &supportedIDs[i];
             *matchingIndex = i;
+            return &supportedIDs[i];
         }
         else if (cmp > 0)
             indexLow = i + 1;
         else
             indexHigh = i - 1;
+
+        i = (indexLow + indexHigh) / 2;
     }
-    return impl;
+    return NULL;
 }
 
 /*****************************************************************************
-- 
1.7.7




More information about the wine-patches mailing list