diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-02-25 13:16:36 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-02-25 13:24:53 +0100 |
commit | 33d31c0e60502a926e68b653055a4744166c5e3d (patch) | |
tree | 7b50f70386fa013e31d19c4097c1446e58c2a073 /src/basic/env-util.c | |
parent | 9c274488a9168f8284dc99882856ca79ce2aa132 (diff) | |
download | systemd-33d31c0e60502a926e68b653055a4744166c5e3d.tar.gz |
env-util: fix parameter handling of parse_env_extension_hierarchies() + getenv_path_list()
Our coding style dictates we should not clobber return parameters on
failure, and always initialize them on success. Do so here.
This changes getenv_path_list() to return ENXIO if the env var is not
set, which is similar to how we handle this in getenv_bool().
This drops debug logging from parse_env_extension_hierarchies(), since
it's done anyway in getenv_path_list()
Follow-up for: #18018
Diffstat (limited to 'src/basic/env-util.c')
-rw-r--r-- | src/basic/env-util.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/basic/env-util.c b/src/basic/env-util.c index 7fa598a3b5..c110a750a5 100644 --- a/src/basic/env-util.c +++ b/src/basic/env-util.c @@ -813,11 +813,9 @@ int getenv_path_list(const char *name, char ***ret_paths) { assert(name); assert(ret_paths); - *ret_paths = NULL; - e = secure_getenv(name); if (!e) - return 0; + return -ENXIO; r = strv_split_full(&l, e, ":", EXTRACT_DONT_COALESCE_SEPARATORS); if (r < 0) @@ -842,5 +840,5 @@ int getenv_path_list(const char *name, char ***ret_paths) { "No paths specified, refusing."); *ret_paths = TAKE_PTR(l); - return 0; + return 1; } |