From: Martin Schwenke Date: Mon, 23 May 2016 04:41:43 +0000 (+1000) Subject: ctdb-ipalloc: Move if-statement with broken condition X-Git-Tag: tdb-1.3.10~554 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=03b300e0522eea97e8f894dc65240f0ed6e007f0;p=thirdparty%2Fsamba.git ctdb-ipalloc: Move if-statement with broken condition This pointer is for an array that is always allocated. The check is meant to skip a node that has no IP addresses. However, when there are no IP addresses the loop below will not do anything anyway. Add this as a check at the beginning of the function instead. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index cb431b3846d..e969ab393e8 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -1240,17 +1240,17 @@ create_merged_ip_list(struct ctdb_context *ctdb, struct ipalloc_state *ipalloc_s TALLOC_FREE(ctdb->ip_tree); ctdb->ip_tree = trbt_create(ctdb, 0); + if (ipalloc_state->known_public_ips == NULL) { + DEBUG(DEBUG_ERR, ("Known public IPs not set\n")); + return NULL; + } + for (i=0; i < ctdb->num_nodes; i++) { if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) { continue; } - /* there were no public ips for this node */ - if (ipalloc_state->known_public_ips == NULL) { - continue; - } - public_ips = &ipalloc_state->known_public_ips[i]; for (j=0; j < public_ips->num; j++) {