diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-12-07 10:51:03 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-12-07 12:34:12 +0100 |
commit | cccb78f09363140d873e8d26355593e22d0cfcea (patch) | |
tree | 3756c0d8d47e8e44789e96c203988050e78bb86d /src/sulogin-shell | |
parent | e821f6a916c19f148435038be21faeb49beac68c (diff) | |
download | systemd-cccb78f09363140d873e8d26355593e22d0cfcea.tar.gz |
sulogin-shell: simplify returns from a function
This is actually slightly safer because it allows gcc to make sure that all code
paths either call return or are noreturn. But the real motivation is just to
follow the usual style and make it a bit shorter.
Diffstat (limited to 'src/sulogin-shell')
-rw-r--r-- | src/sulogin-shell/sulogin-shell.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c index b21d61d317..6dbe0935cb 100644 --- a/src/sulogin-shell/sulogin-shell.c +++ b/src/sulogin-shell/sulogin-shell.c @@ -57,14 +57,12 @@ static int start_default_target(void) { return r; } -static void fork_wait(const char* const cmdline[]) { +static int fork_wait(const char* const cmdline[]) { pid_t pid; pid = fork(); - if (pid < 0) { - log_error_errno(errno, "fork(): %m"); - return; - } + if (pid < 0) + return log_error_errno(errno, "fork(): %m"); if (pid == 0) { /* Child */ @@ -78,7 +76,7 @@ static void fork_wait(const char* const cmdline[]) { _exit(EXIT_FAILURE); /* Operational error */ } - wait_for_terminate_and_warn(cmdline[0], pid, false); + return wait_for_terminate_and_warn(cmdline[0], pid, false); } static void print_mode(const char* mode) { @@ -98,7 +96,7 @@ int main(int argc, char *argv[]) { print_mode(argc > 1 ? argv[1] : ""); - fork_wait(sulogin_cmdline); + (void) fork_wait(sulogin_cmdline); r = start_default_target(); |