From 116f62a7b33c1b1b65fc6ab307d2377db4cc561f Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 23 May 2013 19:01:01 +1000 Subject: [PATCH] recoverd: Set explicit default value when getting tunable from nodes Both of the current defaults are implicitly 0. It is better to make the defaults obvious. Signed-off-by: Martin Schwenke (This used to be ctdb commit 1190bb0d9c14dc5889c2df56f6c8986db23d81a1) --- ctdb/server/ctdb_takeover.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index a8ca72182e2..a978ec833cb 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -2267,16 +2267,22 @@ static void get_tunable_callback(struct ctdb_context *ctdb, uint32_t pnn, static uint32_t *get_tunable_from_nodes(struct ctdb_context *ctdb, TALLOC_CTX *tmp_ctx, struct ctdb_node_map *nodemap, - const char *tunable) + const char *tunable, + uint32_t default_value) { TDB_DATA data; struct ctdb_control_get_tunable *t; uint32_t *nodes; uint32_t *tvals; struct get_tunable_callback_data callback_data; + int i; - tvals = talloc_zero_array(tmp_ctx, uint32_t, nodemap->num); + tvals = talloc_array(tmp_ctx, uint32_t, nodemap->num); CTDB_NO_MEMORY_NULL(ctdb, tvals); + for (i=0; inum; i++) { + tvals[i] = default_value; + } + callback_data.out = tvals; callback_data.tunable = tunable; @@ -2366,15 +2372,16 @@ static struct ctdb_ipflags *set_ipflags(struct ctdb_context *ctdb, struct ctdb_ipflags *ipflags; tval_noiptakeover = get_tunable_from_nodes(ctdb, tmp_ctx, nodemap, - "NoIPTakeover"); + "NoIPTakeover", 0); if (tval_noiptakeover == NULL) { return NULL; } tval_noiphostonalldisabled = get_tunable_from_nodes(ctdb, tmp_ctx, nodemap, - "NoIPHostOnAllDisabled"); + "NoIPHostOnAllDisabled", 0); if (tval_noiphostonalldisabled == NULL) { + /* Caller frees tmp_ctx */ return NULL; } -- 2.11.4.GIT