core,systemctl: unit_file_find_fragment() provides names with string_hash_ops_free

names are assigned with set_put_strdup(), hence string_hash_ops_free is
used and we can use set_free() rather than set_free_free().
This commit is contained in:
Yu Watanabe
2025-04-13 09:49:40 +09:00
parent c4c4ea2fb6
commit 5793a39dd8
3 changed files with 5 additions and 6 deletions
+2 -2
View File
@@ -6178,8 +6178,6 @@ static int merge_by_names(Unit *u, Set *names, const char *id) {
}
int unit_load_fragment(Unit *u) {
const char *fragment;
_cleanup_set_free_free_ Set *names = NULL;
int r;
assert(u);
@@ -6201,6 +6199,8 @@ int unit_load_fragment(Unit *u) {
if (r < 0)
return log_error_errno(r, "Failed to rebuild name map: %m");
const char *fragment;
_cleanup_set_free_ Set *names = NULL;
r = unit_file_find_fragment(u->manager->unit_id_map,
u->manager->unit_name_map,
u->id,
+2 -3
View File
@@ -569,15 +569,14 @@ int unit_find_paths(
return log_error_errno(r, "Failed to get DropInPaths: %s", bus_error_message(&error, r));
}
} else {
const char *_path;
_cleanup_set_free_free_ Set *names = NULL;
if (!*cached_name_map) {
r = unit_file_build_name_map(lp, NULL, cached_id_map, cached_name_map, NULL);
if (r < 0)
return r;
}
const char *_path;
_cleanup_set_free_ Set *names = NULL;
r = unit_file_find_fragment(*cached_id_map, *cached_name_map, unit_name, &_path, &names);
if (r < 0)
return log_error_errno(r, "Failed to find fragment for '%s': %m", unit_name);
+1 -1
View File
@@ -63,7 +63,7 @@ TEST(unit_file_build_name_map) {
STRV_FOREACH(id, ids) {
const char *fragment, *name;
_cleanup_set_free_free_ Set *names = NULL;
_cleanup_set_free_ Set *names = NULL;
log_info("*** %s ***", *id);
r = unit_file_find_fragment(unit_ids,
unit_names,