summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-04-13 09:10:17 +0200
committerGitHub <noreply@github.com>2023-04-13 09:10:17 +0200
commit39857544ee3794481f165e6ecc5d5a81c65f0ee9 (patch)
tree2404d8531594f1d31f8dfa7cb29024a1d41049d8 /src/core
parent37734dc677df0ac9ddc837d11aa3f5002a4d67a0 (diff)
parente7f5525fb0a7c8eff98b2b1b5e94e25b95fed782 (diff)
downloadsystemd-39857544ee3794481f165e6ecc5d5a81c65f0ee9.tar.gz
Merge pull request #27027 from dtardon/unit-file-list-cleanup
Use _cleanup_ for UnitFileList hash
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dbus-manager.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 8fdca2da22..2feec0bd7d 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -2094,7 +2094,7 @@ static int list_unit_files_by_patterns(sd_bus_message *message, void *userdata,
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = ASSERT_PTR(userdata);
UnitFileList *item;
- Hashmap *h;
+ _cleanup_(hashmap_freep) Hashmap *h = NULL;
int r;
assert(message);
@@ -2109,36 +2109,30 @@ static int list_unit_files_by_patterns(sd_bus_message *message, void *userdata,
if (r < 0)
return r;
- h = hashmap_new(&string_hash_ops);
+ h = hashmap_new(&unit_file_list_hash_ops_free);
if (!h)
return -ENOMEM;
r = unit_file_get_list(m->runtime_scope, NULL, h, states, patterns);
if (r < 0)
- goto fail;
+ return r;
r = sd_bus_message_open_container(reply, 'a', "(ss)");
if (r < 0)
- goto fail;
+ return r;
HASHMAP_FOREACH(item, h) {
r = sd_bus_message_append(reply, "(ss)", item->path, unit_file_state_to_string(item->state));
if (r < 0)
- goto fail;
+ return r;
}
- unit_file_list_free(h);
-
r = sd_bus_message_close_container(reply);
if (r < 0)
return r;
return sd_bus_send(NULL, reply, NULL);
-
-fail:
- unit_file_list_free(h);
- return r;
}
static int method_list_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) {