path-lookup: rename lookup_paths_free -> _done

This is stack-allocated, so update to match our usual rules.
This commit is contained in:
Mike Yuan
2024-03-02 16:38:17 +08:00
parent da920fe176
commit 7dfc71399d
15 changed files with 36 additions and 37 deletions

View File

@@ -15,7 +15,7 @@ static bool strv_fnmatch_strv_or_empty(char* const* patterns, char **strv, int f
int verb_unit_files(int argc, char *argv[], void *userdata) {
_cleanup_hashmap_free_ Hashmap *unit_ids = NULL, *unit_names = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
char **patterns = strv_skip(argv, 1);
const char *k, *dst;
char **v;

View File

@@ -6,7 +6,7 @@
#include "strv.h"
int verb_unit_paths(int argc, char *argv[], void *userdata) {
_cleanup_(lookup_paths_free) LookupPaths paths = {};
_cleanup_(lookup_paths_done) LookupPaths paths = {};
int r;
r = lookup_paths_init_or_warn(&paths, arg_runtime_scope, 0, NULL);

View File

@@ -776,9 +776,8 @@ int lookup_paths_init_or_warn(LookupPaths *lp, RuntimeScope scope, LookupPathsFl
return r;
}
void lookup_paths_free(LookupPaths *lp) {
if (!lp)
return;
void lookup_paths_done(LookupPaths *lp) {
assert(lp);
lp->search_path = strv_free(lp->search_path);

View File

@@ -65,7 +65,7 @@ bool path_is_user_data_dir(const char *path);
bool path_is_user_config_dir(const char *path);
void lookup_paths_log(LookupPaths *p);
void lookup_paths_free(LookupPaths *p);
void lookup_paths_done(LookupPaths *p);
char **generator_binary_paths(RuntimeScope scope);
char **env_generator_binary_paths(RuntimeScope scope);

View File

@@ -1668,7 +1668,7 @@ Manager* manager_free(Manager *m) {
free(m->notify_socket);
lookup_paths_free(&m->lookup_paths);
lookup_paths_done(&m->lookup_paths);
strv_free(m->transient_environment);
strv_free(m->client_environment);
@@ -3557,7 +3557,7 @@ int manager_reload(Manager *m) {
manager_clear_jobs_and_units(m);
lookup_paths_flush_generator(&m->lookup_paths);
lookup_paths_free(&m->lookup_paths);
lookup_paths_done(&m->lookup_paths);
exec_shared_runtime_vacuum(m);
dynamic_user_vacuum(m, false);
m->uid_refs = hashmap_free(m->uid_refs);

View File

@@ -596,7 +596,7 @@ static int get_search(uint64_t type, char ***list) {
case SD_PATH_SYSTEMD_SEARCH_SYSTEM_UNIT:
case SD_PATH_SYSTEMD_SEARCH_USER_UNIT: {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
RuntimeScope scope = type == SD_PATH_SYSTEMD_SEARCH_SYSTEM_UNIT ?
RUNTIME_SCOPE_SYSTEM : RUNTIME_SCOPE_USER;

View File

@@ -182,7 +182,7 @@ static int extract_now(
_cleanup_hashmap_free_ Hashmap *unit_files = NULL;
_cleanup_(portable_metadata_unrefp) PortableMetadata *os_release = NULL;
_cleanup_(lookup_paths_free) LookupPaths paths = {};
_cleanup_(lookup_paths_done) LookupPaths paths = {};
_cleanup_close_ int os_release_fd = -EBADF;
_cleanup_free_ char *os_release_path = NULL;
const char *os_release_id;
@@ -1556,7 +1556,7 @@ int portable_attach(
_cleanup_ordered_hashmap_free_ OrderedHashmap *extension_images = NULL, *extension_releases = NULL;
_cleanup_(portable_metadata_unrefp) PortableMetadata *os_release = NULL;
_cleanup_hashmap_free_ Hashmap *unit_files = NULL;
_cleanup_(lookup_paths_free) LookupPaths paths = {};
_cleanup_(lookup_paths_done) LookupPaths paths = {};
_cleanup_strv_free_ char **valid_prefixes = NULL;
_cleanup_(image_unrefp) Image *image = NULL;
PortableMetadata *item;
@@ -1817,7 +1817,7 @@ int portable_detach(
size_t *n_changes,
sd_bus_error *error) {
_cleanup_(lookup_paths_free) LookupPaths paths = {};
_cleanup_(lookup_paths_done) LookupPaths paths = {};
_cleanup_set_free_ Set *unit_files = NULL, *markers = NULL;
_cleanup_free_ char *extensions = NULL;
_cleanup_closedir_ DIR *d = NULL;
@@ -2002,7 +2002,7 @@ static int portable_get_state_internal(
PortableState *ret,
sd_bus_error *error) {
_cleanup_(lookup_paths_free) LookupPaths paths = {};
_cleanup_(lookup_paths_done) LookupPaths paths = {};
bool found_enabled = false, found_running = false;
_cleanup_set_free_ Set *unit_files = NULL;
_cleanup_closedir_ DIR *d = NULL;

View File

@@ -2259,7 +2259,7 @@ int unit_file_mask(
InstallChange **changes,
size_t *n_changes) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
const char *config_path;
int r;
@@ -2302,7 +2302,7 @@ int unit_file_unmask(
InstallChange **changes,
size_t *n_changes) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
_cleanup_strv_free_ char **todo = NULL;
const char *config_path;
@@ -2414,7 +2414,7 @@ int unit_file_link(
InstallChange **changes,
size_t *n_changes) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_strv_free_ char **todo = NULL;
const char *config_path;
size_t n_todo = 0;
@@ -2522,7 +2522,7 @@ int unit_file_revert(
size_t *n_changes) {
_cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_strv_free_ char **todo = NULL;
size_t n_todo = 0;
int r, q;
@@ -2680,7 +2680,7 @@ int unit_file_add_dependency(
InstallChange **changes,
size_t *n_changes) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_(install_context_done) InstallContext ctx = { .scope = scope };
InstallInfo *info, *target_info;
const char *config_path;
@@ -2781,7 +2781,7 @@ int unit_file_enable(
InstallChange **changes,
size_t *n_changes) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
int r;
assert(scope >= 0);
@@ -2849,7 +2849,7 @@ int unit_file_disable(
InstallChange **changes,
size_t *n_changes) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
int r;
assert(scope >= 0);
@@ -2932,7 +2932,7 @@ int unit_file_reenable(
InstallChange **changes,
size_t *n_changes) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_strv_free_ char **names = NULL, **files = NULL;
int r;
@@ -2968,7 +2968,7 @@ int unit_file_set_default(
InstallChange **changes,
size_t *n_changes) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_(install_context_done) InstallContext ctx = { .scope = scope };
InstallInfo *info;
const char *new_path;
@@ -3000,7 +3000,7 @@ int unit_file_get_default(
const char *root_dir,
char **name) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_(install_context_done) InstallContext ctx = { .scope = scope };
InstallInfo *info;
char *n;
@@ -3131,7 +3131,7 @@ int unit_file_get_state(
const char *name,
UnitFileState *ret) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
int r;
assert(scope >= 0);
@@ -3558,7 +3558,7 @@ int unit_file_preset(
size_t *n_changes) {
_cleanup_(install_context_done) InstallContext plus = {}, minus = {};
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_(unit_file_presets_done) UnitFilePresets presets = {};
const char *config_path;
int r;
@@ -3597,7 +3597,7 @@ int unit_file_preset_all(
size_t *n_changes) {
_cleanup_(install_context_done) InstallContext plus = {}, minus = {};
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_(unit_file_presets_done) UnitFilePresets presets = {};
const char *config_path = NULL;
int r;
@@ -3674,7 +3674,7 @@ int unit_file_get_list(
char **states,
char **patterns) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
int r;
assert(scope >= 0);

View File

@@ -458,7 +458,7 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
if (r < 0)
return log_error_errno(r, "Failed to determine if sshd is installed: %m");
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
r = lookup_paths_init_or_warn(&lp, RUNTIME_SCOPE_SYSTEM, LOOKUP_PATHS_EXCLUDE_GENERATED, /* root_dir= */ NULL);
if (r < 0)
return r;

View File

@@ -15,7 +15,7 @@
int verb_cat(int argc, char *argv[], void *userdata) {
_cleanup_hashmap_free_ Hashmap *cached_id_map = NULL, *cached_name_map = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_strv_free_ char **names = NULL;
sd_bus *bus;
bool first = true;
@@ -198,7 +198,7 @@ static int find_paths_to_edit(
char **names) {
_cleanup_hashmap_free_ Hashmap *cached_id_map = NULL, *cached_name_map = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_free_ char *drop_in_alloc = NULL, *suffix = NULL;
const char *drop_in;
int r;

View File

@@ -143,7 +143,7 @@ int verb_enable(int argc, char *argv[], void *userdata) {
bool warn_trigger_ignore_masked = true; /* suppress "used uninitialized" warning */
if (STR_IN_SET(verb, "mask", "unmask")) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
r = lookup_paths_init_or_warn(&lp, arg_runtime_scope, 0, arg_root);
if (r < 0)

View File

@@ -111,7 +111,7 @@ int enable_sysv_units(const char *verb, char **args) {
int r = 0;
#if HAVE_SYSV_COMPAT
_cleanup_(lookup_paths_free) LookupPaths paths = {};
_cleanup_(lookup_paths_done) LookupPaths paths = {};
unsigned f = 0;
SysVUnitEnableState enable_state = SYSV_UNIT_NOT_FOUND;

View File

@@ -894,7 +894,7 @@ finish:
static int run(const char *dest, const char *dest_early, const char *dest_late) {
_cleanup_(free_sysvstub_hashmapp) Hashmap *all_services = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
SysvStub *service;
int r;

View File

@@ -13,8 +13,8 @@
static void test_paths_one(RuntimeScope scope) {
_cleanup_(rm_rf_physical_and_freep) char *tmp = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp_without_env = {};
_cleanup_(lookup_paths_free) LookupPaths lp_with_env = {};
_cleanup_(lookup_paths_done) LookupPaths lp_without_env = {};
_cleanup_(lookup_paths_done) LookupPaths lp_with_env = {};
char *systemd_unit_path;
assert_se(mkdtemp_malloc("/tmp/test-path-lookup.XXXXXXX", &tmp) >= 0);
@@ -40,7 +40,7 @@ TEST(paths) {
}
TEST(user_and_global_paths) {
_cleanup_(lookup_paths_free) LookupPaths lp_global = {}, lp_user = {};
_cleanup_(lookup_paths_done) LookupPaths lp_global = {}, lp_user = {};
char **u, **g;
unsigned k = 0;

View File

@@ -26,7 +26,7 @@ TEST(unit_validate_alias_symlink_and_warn) {
}
TEST(unit_file_build_name_map) {
_cleanup_(lookup_paths_free) LookupPaths lp = {};
_cleanup_(lookup_paths_done) LookupPaths lp = {};
_cleanup_hashmap_free_ Hashmap *unit_ids = NULL;
_cleanup_hashmap_free_ Hashmap *unit_names = NULL;
const char *k, *dst;