From 33d31c0e60502a926e68b653055a4744166c5e3d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 25 Feb 2021 13:16:36 +0100 Subject: 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 --- src/basic/env-util.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/basic/env-util.c') 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; } -- cgit v1.2.1