commit 8be98d6149101e6ffd04debedcb6ecdcc238cbfe
parent 0d900cf2507e4468d847b65e8f760fb7a0d99dd2
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Tue, 17 Sep 2019 14:09:11 -0700
client: Change semantics of return value from command_init
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.
Diffstat:
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git 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
@@ -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();