Blob Blame History Raw
From 66b979b8d59a422dfbc7660016a09be44bc979f6 Mon Sep 17 00:00:00 2001
From: Alexey Tikhonov <atikhono@redhat.com>
Date: Mon, 28 Jan 2019 17:50:17 +0100
Subject: [PATCH 1/9] providers/proxy: small optimization
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Small optimization of for-loops in
proxy_id.c:remove_duplicate_group_members()

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
(cherry picked from commit feb08323cc80cd8a487f991c04e99c3c2d4c5daf)

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
---
 src/providers/proxy/proxy_id.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/providers/proxy/proxy_id.c b/src/providers/proxy/proxy_id.c
index e82e60336..478709f69 100644
--- a/src/providers/proxy/proxy_id.c
+++ b/src/providers/proxy/proxy_id.c
@@ -602,9 +602,9 @@ static errno_t remove_duplicate_group_members(TALLOC_CTX *mem_ctx,
         goto done;
     }
 
-    for (i=0; orig_grp->gr_mem[i] != NULL; i++) {
-        orig_member_count++;
-    }
+    for (i=0; orig_grp->gr_mem[i] != NULL; ++i) /* no-op: just counting */;
+
+    orig_member_count = i;
 
     if (orig_member_count == 0) {
         ret = ENOENT;
@@ -618,7 +618,7 @@ static errno_t remove_duplicate_group_members(TALLOC_CTX *mem_ctx,
         goto done;
     }
 
-    for (i=0; orig_grp->gr_mem[i] != NULL; i++) {
+    for (i=0; i < orig_member_count; ++i) {
         key.type = HASH_KEY_STRING;
         key.str = talloc_strdup(member_tbl, orig_grp->gr_mem[i]);
         if (key.str == NULL) {
-- 
2.21.1