]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vmspawn: simplify kernel_cmdline_maybe_append_root() 41485/head
authorLennart Poettering <lennart@amutable.com>
Thu, 2 Apr 2026 21:03:11 +0000 (23:03 +0200)
committerLennart Poettering <lennart@amutable.com>
Thu, 2 Apr 2026 21:28:33 +0000 (23:28 +0200)
src/vmspawn/vmspawn.c

index 4061c6c9eedaaa2c84d5b2c2286fb50bfe004c82..5d0962daf6104bf23d90707c27863b96c9c5195f 100644 (file)
@@ -1876,22 +1876,20 @@ static int bind_user_setup(
 
 static int kernel_cmdline_maybe_append_root(void) {
         int r;
-        bool cmdline_contains_root = strv_find_startswith(arg_kernel_cmdline_extra, "root=")
-                        || strv_find_startswith(arg_kernel_cmdline_extra, "mount.usr=");
 
-        if (!cmdline_contains_root) {
-                _cleanup_free_ char *root = NULL;
+        if (strv_find_startswith(arg_kernel_cmdline_extra, "root=") ||
+            strv_find_startswith(arg_kernel_cmdline_extra, "mount.usr="))
+                return 0;
 
-                r = discover_root(&root);
-                if (r < 0)
-                        return r;
+        _cleanup_free_ char *root = NULL;
+        r = discover_root(&root);
+        if (r < 0)
+                return r;
 
-                log_debug("Determined root file system %s from dissected image", root);
+        log_debug("Determined root file system '%s' from dissected image", root);
 
-                r = strv_consume(&arg_kernel_cmdline_extra, TAKE_PTR(root));
-                if (r < 0)
-                        return log_oom();
-        }
+        if (strv_consume(&arg_kernel_cmdline_extra, TAKE_PTR(root)) < 0)
+                return log_oom();
 
         return 0;
 }