s4:registry: Fix size type and loop
authorAndreas Schneider <asn@samba.org>
Wed, 21 Mar 2018 15:46:49 +0000 (16:46 +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/lib/registry/tools/regshell.c

index 5308d30e84967b23deb4149dba2bdfa9540b7d5b..48251c33ea4a038f22b80749067c8b3c9c3bd8c9 100644 (file)
@@ -428,7 +428,7 @@ static char **reg_complete_command(const char *text, int start, int end)
        /* Complete command */
        char **matches;
        size_t len, samelen=0;
-       int i, count=1;
+       size_t i, count = 1;
 
        matches = malloc_array_p(char *, MAX_COMPLETIONS);
        if (!matches) return NULL;
@@ -463,10 +463,8 @@ static char **reg_complete_command(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;