]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-lookup: rename lookup_paths_free -> _done
authorMike Yuan <me@yhndnzj.com>
Sat, 2 Mar 2024 08:38:17 +0000 (16:38 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 6 Mar 2024 18:01:57 +0000 (02:01 +0800)
This is stack-allocated, so update to match our usual rules.

15 files changed:
src/analyze/analyze-unit-files.c
src/analyze/analyze-unit-paths.c
src/basic/path-lookup.c
src/basic/path-lookup.h
src/core/manager.c
src/libsystemd/sd-path/sd-path.c
src/portable/portable.c
src/shared/install.c
src/ssh-generator/ssh-generator.c
src/systemctl/systemctl-edit.c
src/systemctl/systemctl-enable.c
src/systemctl/systemctl-sysv-compat.c
src/sysv-generator/sysv-generator.c
src/test/test-path-lookup.c
src/test/test-unit-file.c

index d9b3313be43e45581b20274d52f71023ec0e7e55..e0c4867c78d1c97c81bf405ccada143c57d033ed 100644 (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;
index bb00a4fcd2c921eb01b84b66f5adf1818768eae9..17f18e0ab6f6ecb80c8ebcdf7d556468a3a237bf 100644 (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);
index 1b31a4e23a52c463fdb840499486f8d9a5afda9b..fbcb1edadc4aafecce9603ec26fb2bc4047f0370 100644 (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);
 
index 11db264c01a297aaa9776329f433bdd612d89d2d..0db2c5a98cafa8ec837ebd9c17a67ab5e1cbbf06 100644 (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);
index 7a7669f315f6fed37a3ae2b268a0ab1e1845e590..d307c07a624eb392bc9707234e593e1837826933 100644 (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);
index 7290d1c40a0e43c32d248cedc27e5c2d8b6dd106..85bca9fd3b758ce2bad59cc4c1e45d22d733adce 100644 (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;
 
index 2012dda835bf58561485e0ba96dda9daf6ebcc56..a003ea03520166aa496ad05f6788ea7e437c9d8c 100644 (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;
index c3a94d191216509018c64d7c43c78c8f8b797a7e..32f504c32763a42470830d13b6fc505cb91e6202 100644 (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);
index 6fdd4ec27f305f256d3efe4ac09d0cc31249f7f7..08532690a9c7581e56c35b47b5646df942c2330b 100644 (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;
index c851c8546ef55c51caba46780ace0ff5bce9d6d9..15398f83646eb8d30bac92ec450df463de9ed0ae 100644 (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;
index 24a1b3d583938798019794a122d520216c869bca..47a19cdd636ebd94769c8f698063add652a2d10f 100644 (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)
index 2aa1ec6d8329b1eb6296e30d5c1b33ae3113d6f7..8ee16eb13f88d9f211f7597709166920da2e2ddd 100644 (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;
 
index 5689a60d785ad87513bb7c5501373e678cc00335..f3b447095a15c3b9cc84b8fc7eaf286e9b5fa655 100644 (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;
 
index 431a85965d904723cc124ffa294b65285f6ad7e1..cb13fad7c5113f1f783f656d202acf07eb5794f9 100644 (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;
 
index 9f8787b49217793f3203f7472ea6f96df2413341..220802e350ba32faed09bb28530baa924253f15e 100644 (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;