]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fstab-generator: drop assertions for mount opts
authorMike Yuan <me@yhndnzj.com>
Thu, 25 Jan 2024 16:47:23 +0000 (00:47 +0800)
committerMike Yuan <me@yhndnzj.com>
Thu, 25 Jan 2024 17:06:40 +0000 (01:06 +0800)
fstab_filter_options accepts NULL and (with later changes)
might even return NULL.

src/fstab-generator/fstab-generator.c

index 3c0b597470a49efe89e216a40286c0a2ad927d14..af17a7d8e24a1f45f6df8e04837acbde5a5e673a 100644 (file)
@@ -481,17 +481,13 @@ static int mandatory_mount_drop_unapplicable_options(
 
         assert(flags);
         assert(where);
-        assert(options);
         assert(ret_options);
 
         if (!(*flags & (MOUNT_NOAUTO|MOUNT_NOFAIL|MOUNT_AUTOMOUNT))) {
-                _cleanup_free_ char *opts = NULL;
-
-                opts = strdup(options);
-                if (!opts)
-                        return -ENOMEM;
+                r = strdup_or_null(options, ret_options);
+                if (r < 0)
+                        return r;
 
-                *ret_options = TAKE_PTR(opts);
                 return 0;
         }
 
@@ -527,7 +523,6 @@ static int add_mount(
 
         assert(what);
         assert(where);
-        assert(opts);
         assert(target_unit);
         assert(source);
 
@@ -840,6 +835,9 @@ static int add_sysusr_sysroot_usr_bind_mount(const char *source) {
 static MountPointFlags fstab_options_to_flags(const char *options, bool is_swap) {
         MountPointFlags flags = 0;
 
+        if (isempty(options))
+                return 0;
+
         if (fstab_test_option(options, "x-systemd.makefs\0"))
                 flags |= MOUNT_MAKEFS;
         if (fstab_test_option(options, "x-systemd.growfs\0"))
@@ -915,7 +913,6 @@ static int parse_fstab_one(
 
         assert(what_original);
         assert(fstype);
-        assert(options);
 
         if (prefix_sysroot && !mount_in_initrd(where_original, options, accept_root))
                 return 0;