diff --git a/src/basic/strv.h b/src/basic/strv.h index e7c2b1a604f..dd3323c2235 100644 --- a/src/basic/strv.h +++ b/src/basic/strv.h @@ -87,6 +87,16 @@ char **strv_parse_nulstr(const char *s, size_t l); char **strv_split_nulstr(const char *s); int strv_make_nulstr(char * const *l, char **p, size_t *n); +static inline int strv_from_nulstr(char ***a, const char *nulstr) { + char **t; + + t = strv_split_nulstr(nulstr); + if (!t) + return -ENOMEM; + *a = t; + return 0; +} + bool strv_overlap(char * const *a, char * const *b) _pure_; #define STRV_FOREACH(s, l) \ diff --git a/src/libsystemd/sd-path/sd-path.c b/src/libsystemd/sd-path/sd-path.c index 5797f55c75a..eed8229f5b8 100644 --- a/src/libsystemd/sd-path/sd-path.c +++ b/src/libsystemd/sd-path/sd-path.c @@ -536,16 +536,11 @@ static int get_search(uint64_t type, char ***list) { "/etc", NULL); - case SD_PATH_SEARCH_BINARIES_DEFAULT: { - char **t; + case SD_PATH_SEARCH_BINARIES_DEFAULT: + return strv_from_nulstr(list, DEFAULT_PATH_NULSTR); - t = strv_split_nulstr(DEFAULT_PATH_NULSTR); - if (!t) - return -ENOMEM; - *list = t; - return 0; - }} + } return -EOPNOTSUPP; }