From 8be98d6149101e6ffd04debedcb6ecdcc238cbfe Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Tue, 17 Sep 2019 14:09:11 -0700 Subject: [PATCH] client: Change semantics of return value from command_init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of returning the mode of execution, command_init now returns whether we are done and need to exit. Thereafter, the mode of execution is now obtain though the command module’s API. --- client/command.c | 4 ++-- client/main.c | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/client/command.c b/client/command.c index 8ec11b5f..ec3d3457 100644 --- a/client/command.c +++ b/client/command.c @@ -677,7 +677,7 @@ bool command_init(char **argv, int argc) case '?': exit_status = EXIT_FAILURE; - return false; + return true; } } @@ -687,7 +687,7 @@ options_parsed: if (argc < 2) { interactive_mode = true; - return true; + return false; } command_noninteractive.argv = argv; diff --git a/client/main.c b/client/main.c index 6b0c2b22..fd4f194d 100644 --- a/client/main.c +++ b/client/main.c @@ -46,20 +46,18 @@ static void signal_handler(uint32_t signo, void *user_data) int main(int argc, char *argv[]) { int exit_status; - bool interactive; + bool all_done; if (!l_main_init()) return EXIT_FAILURE; l_log_set_stderr(); - interactive = command_init(argv, argc); - - exit_status = command_get_exit_status(); - if (exit_status) + all_done = command_init(argv, argc); + if (all_done) goto done; - if (interactive) + if (command_is_interactive_mode()) display_init(); dbus_proxy_init(); @@ -68,11 +66,12 @@ int main(int argc, char *argv[]) dbus_proxy_exit(); - if (interactive) + if (command_is_interactive_mode()) display_exit(); - exit_status = command_get_exit_status(); done: + exit_status = command_get_exit_status(); + command_exit(); l_main_exit();