From: Yu Watanabe Date: Thu, 17 Jul 2025 16:13:44 +0000 (+0900) Subject: analyze-unit-shell: drop unnecessary error check X-Git-Tag: v258-rc1~36^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33502785de3075b5a42d7df436931da46b01ba86;p=thirdparty%2Fsystemd.git analyze-unit-shell: drop unnecessary error check execl() and friends will not return on success. Follow-up for 9a08000d186396bc8bcb8fe057720417543c3bf0. --- diff --git a/src/analyze/analyze-unit-shell.c b/src/analyze/analyze-unit-shell.c index 6990aa6d9be..43eb65932ee 100644 --- a/src/analyze/analyze-unit-shell.c +++ b/src/analyze/analyze-unit-shell.c @@ -95,23 +95,22 @@ int verb_unit_shell(int argc, char *argv[], void *userdata) { if (r == 0) { if (args) { - r = execvp(args[0], args); - if (r < 0) - log_error_errno(errno, "Failed to execute '%s': %m", *args); + (void) execvp(args[0], args); + log_error_errno(errno, "Failed to execute '%s': %m", *args); } else { - r = execl(DEFAULT_USER_SHELL, "-" DEFAULT_USER_SHELL_NAME, NULL); - if (r < 0) - log_debug_errno(errno, "Failed to execute '" DEFAULT_USER_SHELL "', ignoring: %m"); + (void) execl(DEFAULT_USER_SHELL, "-" DEFAULT_USER_SHELL_NAME, NULL); + log_debug_errno(errno, "Failed to execute '" DEFAULT_USER_SHELL "', ignoring: %m"); + if (!streq(DEFAULT_USER_SHELL, "/bin/bash")) { - r = execl("/bin/bash", "-bash", NULL); - if (r < 0) - log_debug_errno(errno, "Failed to execute '/bin/bash', ignoring: %m"); + (void) execl("/bin/bash", "-bash", NULL); + log_debug_errno(errno, "Failed to execute '/bin/bash', ignoring: %m"); } + if (!streq(DEFAULT_USER_SHELL, "/bin/sh")) { - r = execl("/bin/sh", "-sh", NULL); - if (r < 0) - log_debug_errno(errno, "Failed to execute '/bin/sh', ignoring: %m"); + (void) execl("/bin/sh", "-sh", NULL); + log_debug_errno(errno, "Failed to execute '/bin/sh', ignoring: %m"); } + log_error_errno(errno, "Failed to execute '" DEFAULT_USER_SHELL "', '/bin/bash', and '/bin/sh': %m"); } _exit(EXIT_FAILURE);