From: Yu Watanabe Date: Thu, 23 Nov 2023 20:19:10 +0000 (+0900) Subject: analyze: shorten code a bit X-Git-Tag: v255-rc4~59^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c131e8b706d43f9ebd895dee3a8731a8664af90e;p=thirdparty%2Fsystemd.git analyze: shorten code a bit No functional change, just refactoring. --- diff --git a/src/analyze/analyze-verify-util.c b/src/analyze/analyze-verify-util.c index cb3d96b6610..54442d06a9e 100644 --- a/src/analyze/analyze-verify-util.c +++ b/src/analyze/analyze-verify-util.c @@ -95,24 +95,16 @@ int verify_generate_path(char **ret, char **filenames) { return r; } - strv_uniq(ans); + joined = strv_join(strv_uniq(ans), ":"); + if (!joined) + return -ENOMEM; /* First, prepend our directories. Second, if some path was specified, use that, and * otherwise use the defaults. Any duplicates will be filtered out in path-lookup.c. - * Treat explicit empty path to mean that nothing should be appended. - */ + * Treat explicit empty path to mean that nothing should be appended. */ old = getenv("SYSTEMD_UNIT_PATH"); - if (!streq_ptr(old, "")) { - if (!old) - old = ""; - - r = strv_extend(&ans, old); - if (r < 0) - return r; - } - - joined = strv_join(ans, ":"); - if (!joined) + if (!streq_ptr(old, "") && + !strextend_with_separator(&joined, ":", old ?: "")) return -ENOMEM; *ret = TAKE_PTR(joined);