util: Fix signed/unsigned comparisons by declaring as size_t
authorMartin Schwenke <martin@meltin.net>
Fri, 21 Jun 2019 05:10:19 +0000 (15:10 +1000)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 1 Jul 2019 06:44:13 +0000 (06:44 +0000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/util/fault.c
lib/util/util_file.c
lib/util/util_strlist.c

index bde20e33460342cae1fb2563bb514d3f3a275554..5be9162679e823522643b2d5f930db46389eaa0e 100644 (file)
@@ -261,10 +261,10 @@ libunwind_failed:
                  (unsigned long)backtrace_size));
 
        if (backtrace_strings) {
-               int i;
+               size_t i;
 
                for (i = 0; i < backtrace_size; i++)
-                       DEBUGADD(0, (" #%u %s\n", i, backtrace_strings[i]));
+                       DEBUGADD(0, (" #%zu %s\n", i, backtrace_strings[i]));
 
                /* Leak the backtrace_strings, rather than risk what free() might do */
        }
index 792761530153e1a9fa8ca25938615eaa48965871..5d92eaafdf420ea1910caa73393d4aeec5c69d24 100644 (file)
@@ -140,7 +140,7 @@ char *fgets_slash(TALLOC_CTX *mem_ctx, char *s2, size_t maxlen, FILE *f)
                            s[len] = 0;
                }
                if ((s2 == NULL) && (len > maxlen-3)) {
-                       int m;
+                       size_t m;
                        char *t;
 
                        m = maxlen * 2;
index 203a643b09baf19cee2adbaa3427a059b77265d6..9462e9c6ad4187eb3d8a80ef9c3b36c212246215 100644 (file)
@@ -361,7 +361,7 @@ _PUBLIC_ const char **str_list_append(const char **list1,
        size_t len1 = str_list_length(list1);
        size_t len2 = str_list_length(list2);
        const char **ret;
-       int i;
+       size_t i;
 
        ret = talloc_realloc(NULL, list1, const char *, len1+len2+1);
        if (ret == NULL) return NULL;
@@ -390,7 +390,7 @@ _PUBLIC_ const char **str_list_unique(const char **list)
 {
        size_t len = str_list_length(list);
        const char **list2;
-       int i, j;
+       size_t i, j;
        if (len < 2) {
                return list;
        }
@@ -435,7 +435,7 @@ _PUBLIC_ const char **str_list_append_const(const char **list1,
        size_t len1 = str_list_length(list1);
        size_t len2 = str_list_length(list2);
        const char **ret;
-       int i;
+       size_t i;
 
        ret = talloc_realloc(NULL, list1, const char *, len1+len2+1);
        if (ret == NULL) return NULL;