From c9575bb333c036e5470d0ff872169cdb4626e023 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Fri, 26 Jun 2020 00:47:12 +0200 Subject: Some more cleanups --- minecctl/minecctl.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'minecctl') diff --git a/minecctl/minecctl.c b/minecctl/minecctl.c index 969b04d..7c01736 100644 --- a/minecctl/minecctl.c +++ b/minecctl/minecctl.c @@ -306,15 +306,9 @@ strv_join(char * const *strv) static void get_known_servers() { - static bool first = true; struct dirent *dent; DIR *dir; - if (!first) - return; - - first = false; - dir = opendir(cfg->cfgdir); if (!dir) { info("Can't open config directory %s: %m", cfg->cfgdir); @@ -366,7 +360,7 @@ set_server(const char *name) } } - error("%s is not a known server", name); + error("\"%s\" is not a known server or command", name); usage(false); } @@ -436,14 +430,12 @@ connect_any(struct list_head *addrs, bool may_fail) break; } - if (!connected) { - if (may_fail) - return -1; - else - die("Failed to connect to remote host"); - } - - return sfd; + if (!connected && may_fail) + return -1; + else if (!connected) + die("Failed to connect to remote host"); + else + return sfd; } static inline void @@ -656,11 +648,9 @@ main(int argc, char **argv) parse_command(&argv[optind]); if (!cfg->cmd) - die("Command not parsed correctly"); + die("Failed to parse command"); if (cfg->server) { - info("Would read file %s", cfg->server->filename); - read_server_config(); } else if (cfg->addrstr) { -- cgit v1.2.3