s4:client: Fix size types and loop
authorAndreas Schneider <asn@samba.org>
Thu, 22 Mar 2018 09:28:02 +0000 (10:28 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 3 Apr 2018 18:20:10 +0000 (20:20 +0200)
This fixes compilation with -Wstrict-overflow=2.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/client/client.c

index f73d9f99d20871277a7570ddeb4a92fb95ffdb6f..284511fb58a825fa39bf9faa7ee29fc8b7ee13ac 100644 (file)
@@ -3053,7 +3053,7 @@ static char **completion_fn(const char *text, int start, int end)
                        return NULL;
        } else {
                char **matches;
-               int i, len, samelen = 0, count=1;
+               size_t i, len, samelen = 0, count=1;
 
                matches = malloc_array_p(char *, MAX_COMPLETIONS);
                if (!matches) return NULL;
@@ -3092,10 +3092,8 @@ static char **completion_fn(const char *text, int start, int end)
                return matches;
 
 cleanup:
-               count--;
-               while (count >= 0) {
-                       free(matches[count]);
-                       count--;
+               for (i = 0; i < count; i++) {
+                       free(matches[i]);
                }
                free(matches);
                return NULL;