]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine: use report_errno_and_exit() in dbus code
authorIvan Kruglov <mail@ikruglov.com>
Thu, 31 Oct 2024 10:01:16 +0000 (11:01 +0100)
committerIvan Kruglov <mail@ikruglov.com>
Fri, 1 Nov 2024 14:21:22 +0000 (15:21 +0100)
src/machine/image-dbus.c

index 2ae61f99b75673d9880c8633bf84c4af35a9f36d..8eca1e4c9589d358015327c8241dd339cf90a914 100644 (file)
@@ -67,14 +67,8 @@ int bus_image_method_remove(
                 return sd_bus_error_set_errnof(error, r, "Failed to fork(): %m");
         if (r == 0) {
                 errno_pipe_fd[0] = safe_close(errno_pipe_fd[0]);
-
                 r = image_remove(image);
-                if (r < 0) {
-                        (void) write(errno_pipe_fd[1], &r, sizeof(r));
-                        _exit(EXIT_FAILURE);
-                }
-
-                _exit(EXIT_SUCCESS);
+                report_errno_and_exit(errno_pipe_fd[1], r);
         }
 
         errno_pipe_fd[1] = safe_close(errno_pipe_fd[1]);
@@ -184,14 +178,8 @@ int bus_image_method_clone(
                 return sd_bus_error_set_errnof(error, r, "Failed to fork(): %m");
         if (r == 0) {
                 errno_pipe_fd[0] = safe_close(errno_pipe_fd[0]);
-
                 r = image_clone(image, new_name, read_only);
-                if (r < 0) {
-                        (void) write(errno_pipe_fd[1], &r, sizeof(r));
-                        _exit(EXIT_FAILURE);
-                }
-
-                _exit(EXIT_SUCCESS);
+                report_errno_and_exit(errno_pipe_fd[1], r);
         }
 
         errno_pipe_fd[1] = safe_close(errno_pipe_fd[1]);