From 63edae360fe5f82380b1382437df7f7f5e2d9db1 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Wed, 11 Sep 2024 17:21:30 +0200 Subject: [PATCH] core/import-creds: use RET_GATHER --- src/core/import-creds.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/core/import-creds.c b/src/core/import-creds.c index 0d830813939..0f35514079e 100644 --- a/src/core/import-creds.c +++ b/src/core/import-creds.c @@ -705,28 +705,26 @@ static int import_credentials_trusted(void) { _cleanup_(import_credentials_context_done) ImportCredentialsContext c = { .target_dir_fd = -EBADF, }; - int q, w, r, y; + int r, ret = 0; /* This is invoked during early boot when no credentials have been imported so far. (Specifically, if * the $CREDENTIALS_DIRECTORY or $ENCRYPTED_CREDENTIALS_DIRECTORY environment variables are not set * yet.) */ - r = import_credentials_qemu(&c); - w = import_credentials_smbios(&c); - q = import_credentials_proc_cmdline(&c); - y = import_credentials_initrd(&c); + RET_GATHER(ret, import_credentials_qemu(&c)); + RET_GATHER(ret, import_credentials_smbios(&c)); + RET_GATHER(ret, import_credentials_proc_cmdline(&c)); + RET_GATHER(ret, import_credentials_initrd(&c)); if (c.n_credentials > 0) { - int z; - log_debug("Imported %u credentials from kernel command line/smbios/fw_cfg/initrd.", c.n_credentials); - z = finalize_credentials_dir(SYSTEM_CREDENTIALS_DIRECTORY, "CREDENTIALS_DIRECTORY"); - if (z < 0) - return z; + r = finalize_credentials_dir(SYSTEM_CREDENTIALS_DIRECTORY, "CREDENTIALS_DIRECTORY"); + if (r < 0) + return r; } - return r < 0 ? r : w < 0 ? w : q < 0 ? q : y; + return ret; } static int merge_credentials_trusted(const char *creds_dir) { -- 2.47.3