shared/install: modernize unit_file_get_list, use key destructor
The rest of the basename()s are easy to drop.
This commit is contained in:
@@ -2187,9 +2187,8 @@ static int method_enqueue_marked_jobs(sd_bus_message *message, void *userdata, s
|
||||
}
|
||||
|
||||
static int list_unit_files_by_patterns(sd_bus_message *message, void *userdata, sd_bus_error *error, char **states, char **patterns) {
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
Manager *m = ASSERT_PTR(userdata);
|
||||
UnitFileList *item;
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
_cleanup_hashmap_free_ Hashmap *h = NULL;
|
||||
int r;
|
||||
|
||||
@@ -2205,11 +2204,7 @@ static int list_unit_files_by_patterns(sd_bus_message *message, void *userdata,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
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);
|
||||
r = unit_file_get_list(m->runtime_scope, /* root_dir = */ NULL, states, patterns, &h);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -2217,8 +2212,8 @@ static int list_unit_files_by_patterns(sd_bus_message *message, void *userdata,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
UnitFileList *item;
|
||||
HASHMAP_FOREACH(item, h) {
|
||||
|
||||
r = sd_bus_message_append(reply, "(ss)", item->path, unit_file_state_to_string(item->state));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user