repart,bootspec: use set_ensure_consume

This commit is contained in:
Mike Yuan
2023-09-08 16:25:12 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent a05fa30f88
commit fc159b2fd9
2 changed files with 4 additions and 5 deletions
+1 -3
View 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;
}
+3 -2
View 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;
}