ctdb-tools: CID 1449530 - Negative loop bound
authorMartin Schwenke <martin@meltin.net>
Wed, 3 Jul 2019 10:58:54 +0000 (20:58 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 5 Jul 2019 06:49:16 +0000 (06:49 +0000)
Regression introduced by commit
2558f96da1f9be8034f26736c8050bb38a1f82a8.  count should be signed
because list_of_connected_nodes() returns -1 on failure.  Variable i
is used in both signed and unsigned contexts, so add new signed
variable j for use in signed context.

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

index 9d46c981a0f5f4954d0105dd5838407a9d406429..2cc72eedc7681da46eba44d174f996d3f6ec7fae 100644 (file)
@@ -3657,7 +3657,8 @@ static int control_reloadnodes(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
        struct ctdb_req_control request;
        struct ctdb_reply_control **reply;
        bool reload;
-       unsigned int i, count;
+       unsigned int i;
+       int count;
        int ret;
        uint32_t *pnn_list;
 
@@ -3726,13 +3727,14 @@ static int control_reloadnodes(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
                                        &request, NULL, &reply);
        if (ret != 0) {
                bool failed = false;
+               int j;
 
-               for (i=0; i<count; i++) {
-                       ret = ctdb_reply_control_reload_nodes_file(reply[i]);
+               for (j=0; j<count; j++) {
+                       ret = ctdb_reply_control_reload_nodes_file(reply[j]);
                        if (ret != 0) {
                                fprintf(stderr,
                                        "Node %u failed to reload nodes\n",
-                                       pnn_list[i]);
+                                       pnn_list[j]);
                                failed = true;
                        }
                }