From: Martin Schwenke Date: Sat, 10 Feb 2024 04:41:38 +0000 (+1100) Subject: ctdb-common: Remove old runstate/string translation functions X-Git-Tag: tdb-1.4.11~1519 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed67e650579b26e30b91775ffaa4ea7765d0b26f;p=thirdparty%2Fsamba.git ctdb-common: Remove old runstate/string translation functions The canonical versions are in protocol utils. These were unused apart from some stray forward declarations in tools/ctdb.c and a single call in ctdb_set_runstate(), where ctdb_runstate_to_string() can be used instead. Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke --- diff --git a/ctdb/common/common.h b/ctdb/common/common.h index 9a73bec1ac6..4f48e8926da 100644 --- a/ctdb/common/common.h +++ b/ctdb/common/common.h @@ -149,10 +149,6 @@ struct ctdb_node_map_old *ctdb_node_list_to_map(struct ctdb_node **nodes, uint32_t num_nodes, TALLOC_CTX *mem_ctx); -const char *runstate_to_string(enum ctdb_runstate runstate); - -enum ctdb_runstate runstate_from_string(const char *label); - void ctdb_set_runstate(struct ctdb_context *ctdb, enum ctdb_runstate runstate); uint32_t *ctdb_key_to_idkey(TALLOC_CTX *mem_ctx, TDB_DATA key); diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c index 5daa69d375b..3ca1f772eba 100644 --- a/ctdb/common/ctdb_util.c +++ b/ctdb/common/ctdb_util.c @@ -595,48 +595,10 @@ ctdb_node_list_to_map(struct ctdb_node **nodes, uint32_t num_nodes, } /* Runstate handling */ -static struct { - enum ctdb_runstate runstate; - const char * label; -} runstate_map[] = { - { CTDB_RUNSTATE_UNKNOWN, "UNKNOWN" }, - { CTDB_RUNSTATE_INIT, "INIT" }, - { CTDB_RUNSTATE_SETUP, "SETUP" }, - { CTDB_RUNSTATE_FIRST_RECOVERY, "FIRST_RECOVERY" }, - { CTDB_RUNSTATE_STARTUP, "STARTUP" }, - { CTDB_RUNSTATE_RUNNING, "RUNNING" }, - { CTDB_RUNSTATE_SHUTDOWN, "SHUTDOWN" }, - { -1, NULL }, -}; - -const char *runstate_to_string(enum ctdb_runstate runstate) -{ - int i; - for (i=0; runstate_map[i].label != NULL ; i++) { - if (runstate_map[i].runstate == runstate) { - return runstate_map[i].label; - } - } - - return runstate_map[0].label; -} - -enum ctdb_runstate runstate_from_string(const char *label) -{ - int i; - for (i=0; runstate_map[i].label != NULL; i++) { - if (strcasecmp(runstate_map[i].label, label) == 0) { - return runstate_map[i].runstate; - } - } - - return CTDB_RUNSTATE_UNKNOWN; -} - void ctdb_set_runstate(struct ctdb_context *ctdb, enum ctdb_runstate runstate) { DEBUG(DEBUG_NOTICE,("Set runstate to %s (%d)\n", - runstate_to_string(runstate), runstate)); + ctdb_runstate_to_string(runstate), runstate)); if (runstate <= ctdb->runstate) { ctdb_fatal(ctdb, "runstate must always increase"); diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 6e8185ff495..3c4bb7ef45d 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -1121,9 +1121,6 @@ static int control_ping(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, return 0; } -const char *runstate_to_string(enum ctdb_runstate runstate); -enum ctdb_runstate runstate_from_string(const char *runstate_str); - static int control_runstate(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb, int argc, const char **argv) {