ctdb-daemon: Make type of list_of_nodes() consistent with callers
authorMartin Schwenke <martin@meltin.net>
Fri, 7 Jun 2019 20:22:49 +0000 (06:22 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 5 Jul 2019 05:03:22 +0000 (05:03 +0000)
Instead of taking exclude_pnn as a parameter, calculate it from an
include_self_parameter, which is passed through from the 2 calling
functions.

While doing this, fix a signed/unsigned comparison issue by declaring
the new exclude_pnn local variable as an unsigned type.

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

index c5ffa121c3da56321f8f620275fbdab30b6792a1..42aa0f5fc3991b6aa5e379d10b009df62825456c 100644 (file)
@@ -1769,18 +1769,19 @@ uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
        return nodes;
 }
 
-/* Get list of nodes not including those with flags specified by mask.
- * If exclude_pnn is not -1 then exclude that pnn from the list.
- */
+/* Get list of nodes not including those with flags specified by mask */
 static uint32_t *list_of_nodes(struct ctdb_context *ctdb,
                               struct ctdb_node_map_old *node_map,
                               TALLOC_CTX *mem_ctx,
                               uint32_t mask,
-                              int exclude_pnn)
+                              bool include_self)
 {
        int i, j, num_nodes;
+       uint32_t exclude_pnn;
        uint32_t *nodes;
 
+       exclude_pnn = include_self ? CTDB_UNKNOWN_PNN : ctdb->pnn;
+
        for (i=num_nodes=0;i<node_map->num;i++) {
                if (node_map->nodes[i].flags & mask) {
                        continue;
@@ -1812,8 +1813,11 @@ uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
                                TALLOC_CTX *mem_ctx,
                                bool include_self)
 {
-       return list_of_nodes(ctdb, node_map, mem_ctx, NODE_FLAGS_INACTIVE,
-                            include_self ? -1 : ctdb->pnn);
+       return list_of_nodes(ctdb,
+                            node_map,
+                            mem_ctx,
+                            NODE_FLAGS_INACTIVE,
+                            include_self);
 }
 
 uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
@@ -1821,8 +1825,11 @@ uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
                                TALLOC_CTX *mem_ctx,
                                bool include_self)
 {
-       return list_of_nodes(ctdb, node_map, mem_ctx, NODE_FLAGS_DISCONNECTED,
-                            include_self ? -1 : ctdb->pnn);
+       return list_of_nodes(ctdb,
+                            node_map,
+                            mem_ctx,
+                            NODE_FLAGS_DISCONNECTED,
+                            include_self);
 }
 
 /*