]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
analyze-unit-shell: drop unnecessary error check
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 17 Jul 2025 16:13:44 +0000 (01:13 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 17 Jul 2025 16:39:51 +0000 (01:39 +0900)
execl() and friends will not return on success.

Follow-up for 9a08000d186396bc8bcb8fe057720417543c3bf0.

src/analyze/analyze-unit-shell.c

index 6990aa6d9be815cb56c7ed5b04598159e9d35ece..43eb65932eecd8daff88443082fed087575e4f36 100644 (file)
@@ -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);