summaryrefslogtreecommitdiffstats
path: root/ctdb/tools
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-03-03 13:04:25 +1100
committerAmitay Isaacs <amitay@samba.org>2014-03-23 04:20:14 +0100
commit555aa06c41e7f77bf241e04ccf771009645e9c27 (patch)
treeeed11f33a622bab1cd5b2ee0e2faa1fddc05beb6 /ctdb/tools
parent91895b33c52c0a81904c3ea36042d4574422f5fd (diff)
downloadsamba-555aa06c41e7f77bf241e04ccf771009645e9c27.tar.gz
samba-555aa06c41e7f77bf241e04ccf771009645e9c27.tar.xz
samba-555aa06c41e7f77bf241e04ccf771009645e9c27.zip
ctdb-tools-ctdb: Use DLIST_ADD_END() to avoid reversing the list
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tools')
-rw-r--r--ctdb/tools/ctdb.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 9cda36cbff4..05bfd0c7994 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -30,6 +30,7 @@
#include "../include/ctdb_private.h"
#include "../common/rb_tree.h"
#include "db_wrap.h"
+#include "lib/util/dlinklist.h"
#define ERR_TIMEOUT 20 /* timed out trying to reach node */
#define ERR_NONODE 21 /* node does not exist */
@@ -811,7 +812,7 @@ static int control_pnn(struct ctdb_context *ctdb, int argc, const char **argv)
struct pnn_node {
- struct pnn_node *next;
+ struct pnn_node *next, *prev;
const char *addr;
int pnn;
};
@@ -824,7 +825,6 @@ static struct pnn_node *read_pnn_node_file(TALLOC_CTX *mem_ctx,
int i, pnn;
struct pnn_node *pnn_nodes = NULL;
struct pnn_node *pnn_node;
- struct pnn_node *tmp_node;
lines = file_lines_load(file, &nlines, mem_ctx);
if (lines == NULL) {
@@ -851,19 +851,8 @@ static struct pnn_node *read_pnn_node_file(TALLOC_CTX *mem_ctx,
pnn_node = talloc(mem_ctx, struct pnn_node);
pnn_node->pnn = pnn++;
pnn_node->addr = talloc_strdup(pnn_node, node);
- pnn_node->next = pnn_nodes;
- pnn_nodes = pnn_node;
- }
-
- /* swap them around so we return them in incrementing order */
- pnn_node = pnn_nodes;
- pnn_nodes = NULL;
- while (pnn_node) {
- tmp_node = pnn_node;
- pnn_node = pnn_node->next;
- tmp_node->next = pnn_nodes;
- pnn_nodes = tmp_node;
+ DLIST_ADD_END(pnn_nodes, pnn_node, NULL);
}
return pnn_nodes;