From 33502785de3075b5a42d7df436931da46b01ba86 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 18 Jul 2025 01:13:44 +0900 Subject: [PATCH] analyze-unit-shell: drop unnecessary error check execl() and friends will not return on success. Follow-up for 9a08000d186396bc8bcb8fe057720417543c3bf0. --- src/analyze/analyze-unit-shell.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/analyze/analyze-unit-shell.c b/src/analyze/analyze-unit-shell.c index 6990aa6d9b..43eb65932e 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);