ctdb: Fix some -Werror=strict-overflow issues
authorMartin Schwenke <martin@meltin.net>
Mon, 16 Apr 2018 08:32:07 +0000 (18:32 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 27 Apr 2018 04:53:16 +0000 (06:53 +0200)
All quite obvious.  For the LCP2 one, we're not actually counting so
use a bool instead of an int.

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

index 2a10b07b508e75cf572a6d4123e5b1ad2238be2c..7495eb3a6741d82b09030557cb0526a902378f40 100644 (file)
@@ -1068,7 +1068,7 @@ static struct tevent_req *push_database_send(
        struct tevent_req *req, *subreq;
        struct push_database_state *state;
        uint32_t *old_list, *new_list;
-       int old_count, new_count;
+       unsigned int old_count, new_count;
        int i;
 
        req = tevent_req_create(mem_ctx, &state, struct push_database_state);
@@ -2359,7 +2359,8 @@ static void recovery_active_done(struct tevent_req *subreq)
        struct ctdb_req_control request;
        struct ctdb_vnn_map *vnnmap;
        int *err_list;
-       int ret, count, i;
+       int ret, i;
+       unsigned int count;
        bool status;
 
        status = ctdb_client_control_multi_recv(subreq, &ret, NULL, &err_list,
index a57000feaffa3021acc67d162c7116cbdfe017a5..565b58c9a0c6537554e66b4b8c8269cd78855566 100644 (file)
@@ -477,7 +477,8 @@ bool ipalloc_lcp2(struct ipalloc_state *ipalloc_state)
 {
        uint32_t *lcp2_imbalances;
        bool *rebalance_candidates;
-       int numnodes, num_rebalance_candidates, i;
+       int numnodes, i;
+       bool have_rebalance_candidates;
        bool ret = true;
 
        unassign_unsuitable_ips(ipalloc_state);
@@ -500,13 +501,14 @@ bool ipalloc_lcp2(struct ipalloc_state *ipalloc_state)
         * continuing on...
         */
        numnodes = ipalloc_state->num;
-       num_rebalance_candidates = 0;
+       have_rebalance_candidates = false;
        for (i=0; i<numnodes; i++) {
                if (rebalance_candidates[i]) {
-                       num_rebalance_candidates++;
+                       have_rebalance_candidates = true;
+                       break;
                }
        }
-       if (num_rebalance_candidates == 0) {
+       if (!have_rebalance_candidates) {
                goto finished;
        }
 
index 0efd71e437fe039cd2bafff6e2628e17f1c62917..e6c37642b956b0c70a9e6c386e21850ef205ffd9 100644 (file)
@@ -3025,7 +3025,8 @@ static int control_tickle(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
 
        if (argc == 0) {
                struct ctdb_connection_list *clist;
-               int i, num_failed;
+               int i;
+               unsigned int num_failed;
 
                /* Client first but the src/dst logic is confused */
                ret = ctdb_connection_list_read(mem_ctx, false, &clist);