]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: use RET_GATHER, return first error
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 9 Jul 2023 19:32:55 +0000 (13:32 -0600)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 13 Jul 2023 09:12:00 +0000 (11:12 +0200)
src/boot/bootctl-status.c
src/boot/bootctl-util.c

index 0bfbf86e10faa43e7ccc9c35fbd16c36aa509ce0..0f2e9204b7a51428aea52b6cbf01f5203e0ca536 100644 (file)
@@ -483,17 +483,11 @@ int verb_status(int argc, char *argv[], void *userdata) {
                        "Not booted with EFI\n\n",
                        ansi_underline(), ansi_normal());
 
-        if (arg_esp_path) {
-                k = status_binaries(arg_esp_path, esp_uuid);
-                if (k < 0)
-                        r = k;
-        }
+        if (arg_esp_path)
+                RET_GATHER(r, status_binaries(arg_esp_path, esp_uuid));
 
-        if (!arg_root && is_efi_boot()) {
-                k = status_variables();
-                if (k < 0)
-                        r = k;
-        }
+        if (!arg_root && is_efi_boot())
+                RET_GATHER(r, status_variables());
 
         if (arg_esp_path || arg_xbootldr_path) {
                 _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL;
@@ -501,15 +495,13 @@ int verb_status(int argc, char *argv[], void *userdata) {
                 k = boot_config_load_and_select(&config,
                                                 arg_esp_path, esp_devid,
                                                 arg_xbootldr_path, xbootldr_devid);
-                if (k < 0)
-                        r = k;
-                else {
-                        k = status_entries(&config,
-                                           arg_esp_path, esp_uuid,
-                                           arg_xbootldr_path, xbootldr_uuid);
-                        if (k < 0)
-                                r = k;
-                }
+                RET_GATHER(r, k);
+
+                if (k >= 0)
+                        RET_GATHER(r,
+                                   status_entries(&config,
+                                                  arg_esp_path, esp_uuid,
+                                                  arg_xbootldr_path, xbootldr_uuid));
         }
 
         return r;
index 6d886aba354edb1d59527ae61b38d0c6030efa01..3cab875fa0647ee2b43f31f49686225c5b04c400 100644 (file)
@@ -4,26 +4,27 @@
 
 #include "bootctl.h"
 #include "bootctl-util.h"
+#include "errno-util.h"
 #include "fileio.h"
 #include "stat-util.h"
 #include "sync-util.h"
 
 int sync_everything(void) {
-        int ret = 0, k;
+        int r = 0, k;
 
         if (arg_esp_path) {
                 k = syncfs_path(AT_FDCWD, arg_esp_path);
                 if (k < 0)
-                        ret = log_error_errno(k, "Failed to synchronize the ESP '%s': %m", arg_esp_path);
+                        RET_GATHER(r, log_error_errno(k, "Failed to synchronize the ESP '%s': %m", arg_esp_path));
         }
 
         if (arg_xbootldr_path) {
                 k = syncfs_path(AT_FDCWD, arg_xbootldr_path);
                 if (k < 0)
-                        ret = log_error_errno(k, "Failed to synchronize $BOOT '%s': %m", arg_xbootldr_path);
+                        RET_GATHER(r, log_error_errno(k, "Failed to synchronize $BOOT '%s': %m", arg_xbootldr_path));
         }
 
-        return ret;
+        return r;
 }
 
 const char *get_efi_arch(void) {