From: Zbigniew Jędrzejewski-Szmek Date: Thu, 7 Dec 2017 09:51:03 +0000 (+0100) Subject: sulogin-shell: simplify returns from a function X-Git-Tag: v236~37^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cccb78f09363140d873e8d26355593e22d0cfcea;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c index b21d61d3178..6dbe0935cbf 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();