ctdb-daemon: Fix signed/unsigned comparisons by declaring as unsigned
authorMartin Schwenke <martin@meltin.net>
Fri, 7 Jun 2019 20:38:56 +0000 (06:38 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 5 Jul 2019 05:03:23 +0000 (05:03 +0000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
15 files changed:
ctdb/include/ctdb_private.h
ctdb/server/ctdb_client.c
ctdb/server/ctdb_daemon.c
ctdb/server/ctdb_freeze.c
ctdb/server/ctdb_keepalive.c
ctdb/server/ctdb_lock_helper.c
ctdb/server/ctdb_ltdb_server.c
ctdb/server/ctdb_persistent.c
ctdb/server/ctdb_server.c
ctdb/server/ctdb_takeover.c
ctdb/server/ctdb_takeover_helper.c
ctdb/server/ctdb_traverse.c
ctdb/server/ctdb_update_record.c
ctdb/server/ctdb_vacuum.c
ctdb/server/eventscript.c

index ea00bb1212807fe05a39c7fd5e91f973f95476e4..9eec244c4f265aee6235650cc9cb496924ddd12a 100644 (file)
@@ -713,7 +713,7 @@ int ctdb_load_persistent_health(struct ctdb_context *ctdb,
 int ctdb_update_persistent_health(struct ctdb_context *ctdb,
                                  struct ctdb_db_context *ctdb_db,
                                  const char *reason,/* NULL means healthy */
-                                 int num_healthy_nodes);
+                                 unsigned int num_healthy_nodes);
 int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
 
 int32_t ctdb_control_db_set_healthy(struct ctdb_context *ctdb,
index 42aa0f5fc3991b6aa5e379d10b009df62825456c..419333025cbed1c4f43347ab04a1005cc058bb54 100644 (file)
@@ -1746,7 +1746,7 @@ uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
                                TALLOC_CTX *mem_ctx,
                                bool include_self)
 {
-       int i, j, num_nodes;
+       unsigned int i, j, num_nodes;
        uint32_t *nodes;
 
        for (i=num_nodes=0;i<vnn_map->size;i++) {
@@ -1776,7 +1776,7 @@ static uint32_t *list_of_nodes(struct ctdb_context *ctdb,
                               uint32_t mask,
                               bool include_self)
 {
-       int i, j, num_nodes;
+       unsigned int i, j, num_nodes;
        uint32_t exclude_pnn;
        uint32_t *nodes;
 
index acb40bdb8df65eaf6abed7a54ff1f173fea7f24e..6a4e42d8010eb05fbdd3c6922ee5f86af98cc8c1 100644 (file)
@@ -1345,7 +1345,7 @@ static void ctdb_create_pidfile(TALLOC_CTX *mem_ctx)
 
 static void ctdb_initialise_vnn_map(struct ctdb_context *ctdb)
 {
-       int i, j, count;
+       unsigned int i, j, count;
 
        /* initialize the vnn mapping table, skipping any deleted nodes */
        ctdb->vnn_map = talloc(ctdb, struct ctdb_vnn_map);
index 10841efa1b9176c7513a403683fb3c2734075681..b4b99a0e5c9a4167b345f704e513f112df83e78f 100644 (file)
@@ -86,7 +86,7 @@ static int db_transaction_start_handler(struct ctdb_db_context *ctdb_db,
 static int db_transaction_commit_handler(struct ctdb_db_context *ctdb_db,
                                         void *private_data)
 {
-       int healthy_nodes = *(int *)private_data;
+       unsigned int healthy_nodes = *(unsigned int *)private_data;
        int ret;
 
        tdb_add_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
@@ -414,7 +414,7 @@ static int db_invalidate(struct ctdb_db_context *ctdb_db, void *private_data)
  */
 static int db_count(struct ctdb_db_context *ctdb_db, void *private_data)
 {
-       int *count = (int *)private_data;
+       unsigned int *count = (unsigned int *)private_data;
 
        *count += 1;
 
@@ -464,7 +464,7 @@ static void ctdb_start_freeze(struct ctdb_context *ctdb)
        ctdb_db_iterator(ctdb, db_invalidate, NULL);
 
        if (ctdb->freeze_mode == CTDB_FREEZE_FROZEN) {
-               int count = 0;
+               unsigned int count = 0;
 
                /*
                 * Check if all the databases are frozen
@@ -711,7 +711,7 @@ static int db_cancel_transaction(struct ctdb_db_context *ctdb_db,
 
 struct db_commit_transaction_state {
        uint32_t transaction_id;
-       int healthy_nodes;
+       unsigned int healthy_nodes;
 };
 
 static int db_commit_transaction(struct ctdb_db_context *ctdb_db,
@@ -809,7 +809,7 @@ int32_t ctdb_control_db_transaction_commit(struct ctdb_context *ctdb,
                (struct ctdb_transdb *)indata.dptr;
        struct ctdb_db_context *ctdb_db;
        struct db_commit_transaction_state state;
-       int healthy_nodes, i;
+       unsigned int healthy_nodes, i;
 
        ctdb_db = find_ctdb_db(ctdb, w->db_id);
        if (ctdb_db == NULL) {
index b4c9d3731c4502763034d7bf4e2fb13793e75770..9155adef3014ebc2809a067f43f8872f2fa1e48f 100644 (file)
@@ -107,7 +107,7 @@ static void ctdb_check_for_dead_nodes(struct tevent_context *ev,
                                      struct timeval t, void *private_data)
 {
        struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
-       int i;
+       unsigned int i;
 
        /* send a keepalive to all other nodes, unless */
        for (i=0;i<ctdb->num_nodes;i++) {
index f918b73dbd37db532d9b23d64d8645d061ab568b..6b6fbbe27a52297088096989154e6136f03b1902 100644 (file)
@@ -86,7 +86,8 @@ static void usage(const char *progname)
 static uint8_t *hex_decode_talloc(TALLOC_CTX *mem_ctx,
                                  const char *hex_in, size_t *len)
 {
-       int i, num;
+       unsigned int i;
+       int num;
        uint8_t *buffer;
 
        *len = strlen(hex_in) / 2;
index 8cc6c4ba4cc6b9e0de86e0a0f781f6cd83f3bac5..022baf62d923144256f086915b0e8960b8d9e721 100644 (file)
@@ -425,7 +425,7 @@ int ctdb_load_persistent_health(struct ctdb_context *ctdb,
 int ctdb_update_persistent_health(struct ctdb_context *ctdb,
                                  struct ctdb_db_context *ctdb_db,
                                  const char *given_reason,/* NULL means healthy */
-                                 int num_healthy_nodes)
+                                 unsigned int num_healthy_nodes)
 {
        struct tdb_context *tdb = ctdb->db_persistent_health->tdb;
        int ret;
index fc2865527474c58119955a9234de810b749cab96..26717441d176bae4f98366be575c253670197515 100644 (file)
@@ -178,7 +178,7 @@ int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
 {
        struct ctdb_client *client;
        struct ctdb_persistent_state *state;
-       int i;
+       unsigned int i;
        struct ctdb_marshall_buffer *m = (struct ctdb_marshall_buffer *)recdata.dptr;
        struct ctdb_db_context *ctdb_db;
 
index c991b85d99b2ff68293fefb47f627f64c9a3e9b4..eb11eb1f95c05861fdb26e9e620e1d3b0003b3f2 100644 (file)
@@ -72,7 +72,7 @@ static int convert_node_map_to_list(struct ctdb_context *ctdb,
                                    struct ctdb_node ***nodes,
                                    uint32_t *num_nodes)
 {
-       int i;
+       unsigned int i;
 
        *nodes = talloc_zero_array(mem_ctx,
                                        struct ctdb_node *, node_map->num);
@@ -157,7 +157,7 @@ int ctdb_set_address(struct ctdb_context *ctdb, const char *address)
 */
 uint32_t ctdb_get_num_active_nodes(struct ctdb_context *ctdb)
 {
-       int i;
+       unsigned int i;
        uint32_t count=0;
        for (i=0; i < ctdb->num_nodes; i++) {
                if (!(ctdb->nodes[i]->flags & NODE_FLAGS_INACTIVE)) {
@@ -383,7 +383,7 @@ static void ctdb_defer_packet(struct ctdb_context *ctdb, struct ctdb_req_header
 static void ctdb_broadcast_packet_all(struct ctdb_context *ctdb, 
                                      struct ctdb_req_header *hdr)
 {
-       int i;
+       unsigned int i;
        for (i=0; i < ctdb->num_nodes; i++) {
                if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
                        continue;
@@ -399,7 +399,7 @@ static void ctdb_broadcast_packet_all(struct ctdb_context *ctdb,
 static void ctdb_broadcast_packet_active(struct ctdb_context *ctdb,
                                         struct ctdb_req_header *hdr)
 {
-       int i;
+       unsigned int i;
        for (i = 0; i < ctdb->num_nodes; i++) {
                if (ctdb->nodes[i]->flags & NODE_FLAGS_INACTIVE) {
                        continue;
@@ -416,7 +416,7 @@ static void ctdb_broadcast_packet_active(struct ctdb_context *ctdb,
 static void ctdb_broadcast_packet_connected(struct ctdb_context *ctdb, 
                                            struct ctdb_req_header *hdr)
 {
-       int i;
+       unsigned int i;
        for (i=0; i < ctdb->num_nodes; i++) {
                if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
                        continue;
index d8dc1c34af5e9d803aa57175cb8090c49d480baa..844e3c32866c232dbb0589e9f06cff3bcdc5f7f9 100644 (file)
@@ -75,9 +75,11 @@ struct ctdb_vnn {
        ctdb_sock_addr public_address;
        uint8_t public_netmask_bits;
 
-       /* the node number that is serving this public address, if any.
-          If no node serves this ip it is set to -1 */
-       int32_t pnn;
+       /*
+        * The node number that is serving this public address - set
+        * to CTDB_UNKNOWN_PNN if node is serving it
+        */
+       uint32_t pnn;
 
        /* List of clients to tickle for this public address */
        struct ctdb_tcp_array *tcp_array;
@@ -370,7 +372,7 @@ static void ctdb_control_send_arp(struct tevent_context *ev,
 {
        struct ctdb_takeover_arp *arp = talloc_get_type(private_data, 
                                                        struct ctdb_takeover_arp);
-       int i, ret;
+       int ret;
        struct ctdb_tcp_array *tcparray;
        const char *iface = ctdb_vnn_iface_string(arp->vnn);
 
@@ -382,6 +384,8 @@ static void ctdb_control_send_arp(struct tevent_context *ev,
 
        tcparray = arp->tcparray;
        if (tcparray) {
+               unsigned int i;
+
                for (i=0;i<tcparray->num;i++) {
                        struct ctdb_connection *tcon;
 
@@ -1366,7 +1370,7 @@ int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
 static struct ctdb_connection *ctdb_tcp_find(struct ctdb_tcp_array *array,
                                           struct ctdb_connection *tcp)
 {
-       int i;
+       unsigned int i;
 
        if (array == NULL) {
                return NULL;
@@ -1949,7 +1953,7 @@ int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA ind
        ctdb_sock_addr *addr = (ctdb_sock_addr *)indata.dptr;
        struct ctdb_tickle_list_old *list;
        struct ctdb_tcp_array *tcparray;
-       int num, i;
+       unsigned int num, i;
        struct ctdb_vnn *vnn;
        unsigned port;
 
@@ -2393,7 +2397,8 @@ static int ctdb_reloadips_child(struct ctdb_context *ctdb)
        TDB_DATA data;
        struct ctdb_client_control_state *state;
        bool first_add;
-       int i, ret;
+       unsigned int i;
+       int ret;
 
        CTDB_NO_MEMORY(ctdb, mem_ctx);
 
index 9aa77d14f1da8dc2bf0a2e2e3c8ea9086ee52ca0..8740838cfdde7c607b82ddfcf49a3ee672bcc5f7 100644 (file)
@@ -692,7 +692,7 @@ struct takeover_state {
        struct tevent_context *ev;
        struct ctdb_client_context *client;
        struct timeval timeout;
-       int num_nodes;
+       unsigned int num_nodes;
        uint32_t *pnns_connected;
        int num_connected;
        uint32_t *pnns_active;
@@ -1076,8 +1076,8 @@ void takeover_failed(struct tevent_req *req, int ret)
                req, struct takeover_state);
        struct tevent_req *subreq;
        uint32_t max_pnn = CTDB_UNKNOWN_PNN;
-       int max_credits = 0;
-       int pnn;
+       unsigned int max_credits = 0;
+       uint32_t pnn;
 
        /* Check that bans are enabled */
        if (state->tun_list->enable_bans == 0) {
index 5ea197095996276fc870b00e8db158f3f4a9a226..4865dcc94f016f5d8f8ffaf6b7359e7a5125127d 100644 (file)
@@ -390,7 +390,7 @@ static struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_
                /* volatile database, traverse all active nodes */
                destination = CTDB_BROADCAST_ACTIVE;
        } else {
-               int i;
+               unsigned int i;
                /* persistent database, traverse one node, preferably
                 * the local one
                 */
index 04b6901ce55eb51d4b41c98c79192df105fe0cb2..405499c81e261a7f9beea1bce8fc116617b273e3 100644 (file)
@@ -53,7 +53,8 @@ struct ctdb_persistent_write_state {
  */
 static int ctdb_persistent_store(struct ctdb_persistent_write_state *state)
 {
-       int ret, i;
+       unsigned int i;
+       int ret;
        struct ctdb_rec_data_old *rec = NULL;
        struct ctdb_marshall_buffer *m = state->m;
 
@@ -73,8 +74,10 @@ static int ctdb_persistent_store(struct ctdb_persistent_write_state *state)
                rec = ctdb_marshall_loop_next(m, rec, NULL, &header, &key, &data);
 
                if (rec == NULL) {
-                       DEBUG(DEBUG_ERR,("Failed to get next record %d for db_id 0x%08x in ctdb_persistent_store\n",
-                                        i, state->ctdb_db->db_id));
+                       D_ERR("Failed to get next record %u for db_id 0x%08x "
+                             "in ctdb_persistent_store\n",
+                             i,
+                             state->ctdb_db->db_id);
                        talloc_free(tmp_ctx);
                        goto failed;
                }
index 9d086917f3c47322cbd5e51c1771880a6cc63f50..0c3770267bc3d09a2cc418b2040c584af10a6650 100644 (file)
@@ -655,7 +655,7 @@ static void ctdb_vacuum_traverse_db(struct ctdb_db_context *ctdb_db,
 static void ctdb_process_vacuum_fetch_lists(struct ctdb_db_context *ctdb_db,
                                            struct vacuum_data *vdata)
 {
-       int i;
+       unsigned int i;
        struct ctdb_context *ctdb = ctdb_db->ctdb;
 
        for (i = 0; i < ctdb->num_nodes; i++) {
@@ -924,7 +924,7 @@ static struct vacuum_data *ctdb_vacuum_init_vacuum_data(
                                        struct ctdb_db_context *ctdb_db,
                                        TALLOC_CTX *mem_ctx)
 {
-       int i;
+       unsigned int i;
        struct ctdb_context *ctdb = ctdb_db->ctdb;
        struct vacuum_data *vdata;
 
index 801e8a85e66b603202544eea33600d7197f9c76c..e7a74468cc2ebe1e3b92942091ccd238b400814b 100644 (file)
@@ -741,7 +741,7 @@ static bool event_allowed_during_recovery(enum ctdb_event event)
                CTDB_EVENT_RELEASE_IP,
                CTDB_EVENT_IPREALLOCATED,
        };
-       int i;
+       size_t i;
 
        for (i = 0; i < ARRAY_SIZE(allowed_events); i++) {
                if (event == allowed_events[i]) {