From: Mike Yuan Date: Thu, 7 Sep 2023 15:28:45 +0000 (+0800) Subject: repart,bootspec: use set_ensure_consume X-Git-Tag: v255-rc1~546 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc159b2fd9382672ea2112789f093041a9e74715;p=thirdparty%2Fsystemd.git repart,bootspec: use set_ensure_consume --- diff --git a/src/partition/repart.c b/src/partition/repart.c index 9325b321005..773874021d5 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -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; } diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index d23eab38df1..42d5fec754c 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -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; }