]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart,bootspec: use set_ensure_consume
authorMike Yuan <me@yhndnzj.com>
Thu, 7 Sep 2023 15:28:45 +0000 (23:28 +0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 8 Sep 2023 14:25:12 +0000 (16:25 +0200)
src/partition/repart.c
src/shared/bootspec.c

index 9325b3210053c8fef62896f1e423509226331132..773874021d59675246421ed94e377ce1eb70b7e5 100644 (file)
@@ -4398,11 +4398,9 @@ static int add_subvolume_path(const char *path, Set **subvolumes) {
         if (r < 0)
                 return log_error_errno(r, "Failed to stat source file '%s/%s': %m", strempty(arg_root), path);
 
-        r = set_ensure_put(subvolumes, &inode_hash_ops, st);
+        r = set_ensure_consume(subvolumes, &inode_hash_ops, TAKE_PTR(st));
         if (r < 0)
                 return log_oom();
-        if (r > 0)
-                TAKE_PTR(st);
 
         return 0;
 }
index d23eab38df11aa707b59fffcd163b890e85f0ddc..42d5fec754c05576fc7b96d3cc5acb90ff3d7243 100644 (file)
@@ -576,13 +576,14 @@ static int config_check_inode_relevant_and_unseen(BootConfig *config, int fd, co
                 log_debug("Inode '%s' already seen before, ignoring.", fname);
                 return false;
         }
+
         d = memdup(&st, sizeof(st));
         if (!d)
                 return log_oom();
-        if (set_ensure_put(&config->inodes_seen, &inode_hash_ops, d) < 0)
+
+        if (set_ensure_consume(&config->inodes_seen, &inode_hash_ops, TAKE_PTR(d)) < 0)
                 return log_oom();
 
-        TAKE_PTR(d);
         return true;
 }