From: Zbigniew Jędrzejewski-Szmek Date: Sun, 9 Jul 2023 19:32:55 +0000 (-0600) Subject: bootctl: use RET_GATHER, return first error X-Git-Tag: v255-rc1~908^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0114bab25f32ada88fcfad4c435a382b0c969d62;p=thirdparty%2Fsystemd.git bootctl: use RET_GATHER, return first error --- diff --git a/src/boot/bootctl-status.c b/src/boot/bootctl-status.c index 0bfbf86e10f..0f2e9204b7a 100644 --- a/src/boot/bootctl-status.c +++ b/src/boot/bootctl-status.c @@ -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; diff --git a/src/boot/bootctl-util.c b/src/boot/bootctl-util.c index 6d886aba354..3cab875fa06 100644 --- a/src/boot/bootctl-util.c +++ b/src/boot/bootctl-util.c @@ -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) {