ctdb-common: Fix signed/unsigned comparisons by declaring as unsigned
authorMartin Schwenke <martin@meltin.net>
Wed, 22 May 2019 11:55:18 +0000 (21:55 +1000)
committerAmitay Isaacs <amitay@samba.org>
Wed, 5 Jun 2019 10:25:49 +0000 (10:25 +0000)
Simple cases where a variable (usually a loop variable) needs to be
declared as an unsigned type (unsigned int or size_t) instead of an
int.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/common/cmdline.c
ctdb/common/logging.c
ctdb/common/run_event.c

index ee360d4c9208231635028b21fbb3f8043706483b..f3768c068fecac94f89837a80b054f87886d2d3e 100644 (file)
@@ -143,7 +143,7 @@ static int cmdline_options_define(TALLOC_CTX *mem_ctx,
        return 0;
 }
 
-static bool cmdline_command_check(struct cmdline_command *cmd, int *max_len)
+static bool cmdline_command_check(struct cmdline_command *cmd, size_t *max_len)
 {
        size_t len;
 
@@ -185,7 +185,7 @@ static bool cmdline_command_check(struct cmdline_command *cmd, int *max_len)
 }
 
 static bool cmdline_commands_check(struct cmdline_command *commands,
-                                  int *max_len)
+                                  size_t *max_len)
 {
        int i;
        bool ok;
@@ -213,7 +213,8 @@ int cmdline_init(TALLOC_CTX *mem_ctx,
                 struct cmdline_context **result)
 {
        struct cmdline_context *cmdline;
-       int ret, max_len = 0;
+       int ret;
+       size_t max_len = 0;
        bool ok;
 
        if (prog == NULL) {
index 7ed500aeb0b365d6630e0d70098db43a2186cd0d..fd763170304503eca6d697ff59becc88db0679c0 100644 (file)
@@ -54,7 +54,7 @@ struct {
 
 bool debug_level_parse(const char *log_string, int *log_level)
 {
-       int i;
+       size_t i;
 
        if (log_string == NULL) {
                return false;
@@ -83,7 +83,7 @@ bool debug_level_parse(const char *log_string, int *log_level)
 
 const char *debug_level_to_string(int log_level)
 {
-       int i;
+       size_t i;
 
        for (i=0; i < ARRAY_SIZE(log_string_map); i++) {
                if (log_string_map[i].log_level == log_level) {
@@ -604,7 +604,7 @@ static int log_backend_parse(TALLOC_CTX *mem_ctx,
 {
        struct log_backend *b = NULL;
        char *t, *name, *option;
-       int i;
+       size_t i;
 
        t = talloc_strdup(mem_ctx, logging);
        if (t == NULL) {
index 91b3dd3241aa4dd941b3cc7cbc8a03e3c253ef59..27e7ad6055e97b48fe14c193384786d63d1eba05 100644 (file)
@@ -101,7 +101,7 @@ static int script_args(TALLOC_CTX *mem_ctx, const char *event_str,
                       const char *arg_str, const char ***out)
 {
        const char **argv;
-       int argc;
+       size_t argc;
        size_t len;
 
        /* Preallocate argv array to avoid reallocation. */
@@ -287,7 +287,8 @@ int run_event_list(struct run_event_context *run_ctx,
 {
        struct event_script_list *s_list;
        struct run_event_script_list *script_list;
-       int ret, i;
+       unsigned int i;
+       int ret;
 
        ret = event_script_get_list(mem_ctx,
                                    run_event_script_dir(run_ctx),