]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/import-creds: use RET_GATHER 39652/head
authorMike Yuan <me@yhndnzj.com>
Wed, 11 Sep 2024 15:21:30 +0000 (17:21 +0200)
committerMike Yuan <me@yhndnzj.com>
Sun, 9 Nov 2025 17:46:37 +0000 (18:46 +0100)
src/core/import-creds.c

index 0d830813939c2322717fc5e6ac7e0129dec8dd8a..0f35514079eed106eebdeb325732efa1fd36f3ba 100644 (file)
@@ -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) {