summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/conf-files.c2
-rw-r--r--src/basic/constants.h8
-rw-r--r--src/basic/path-lookup.c4
-rw-r--r--src/basic/strv.c10
-rw-r--r--src/basic/strv.h5
5 files changed, 12 insertions, 17 deletions
diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c
index 9cb66c099b..7fdcc71356 100644
--- a/src/basic/conf-files.c
+++ b/src/basic/conf-files.c
@@ -369,7 +369,7 @@ int conf_files_list_dropins(
assert(dirs);
suffix = strjoina("/", dropin_dirname);
- r = strv_extend_strv_concat(&dropin_dirs, (char**) dirs, suffix);
+ r = strv_extend_strv_concat(&dropin_dirs, dirs, suffix);
if (r < 0)
return r;
diff --git a/src/basic/constants.h b/src/basic/constants.h
index ef3af88a9d..e70817c51f 100644
--- a/src/basic/constants.h
+++ b/src/basic/constants.h
@@ -64,18 +64,12 @@
"/usr/local/lib/" n "\0" \
"/usr/lib/" n "\0"
-#define CONF_PATHS_USR(n) \
+#define CONF_PATHS(n) \
"/etc/" n, \
"/run/" n, \
"/usr/local/lib/" n, \
"/usr/lib/" n
-#define CONF_PATHS(n) \
- CONF_PATHS_USR(n)
-
-#define CONF_PATHS_USR_STRV(n) \
- STRV_MAKE(CONF_PATHS_USR(n))
-
#define CONF_PATHS_STRV(n) \
STRV_MAKE(CONF_PATHS(n))
diff --git a/src/basic/path-lookup.c b/src/basic/path-lookup.c
index fbcb1edadc..e7fc4a7f06 100644
--- a/src/basic/path-lookup.c
+++ b/src/basic/path-lookup.c
@@ -214,7 +214,7 @@ static char** user_dirs(
persistent_config) < 0)
return NULL;
- if (strv_extend_strv_concat(&res, config_dirs, "/systemd/user") < 0)
+ if (strv_extend_strv_concat(&res, (const char* const*) config_dirs, "/systemd/user") < 0)
return NULL;
/* global config has lower priority than the user config of the same type */
@@ -232,7 +232,7 @@ static char** user_dirs(
data_home) < 0)
return NULL;
- if (strv_extend_strv_concat(&res, data_dirs, "/systemd/user") < 0)
+ if (strv_extend_strv_concat(&res, (const char* const*) data_dirs, "/systemd/user") < 0)
return NULL;
if (strv_extend_strv(&res, (char**) user_data_unit_paths, false) < 0)
diff --git a/src/basic/strv.c b/src/basic/strv.c
index 208108d6c0..d081821a86 100644
--- a/src/basic/strv.c
+++ b/src/basic/strv.c
@@ -242,21 +242,19 @@ rollback:
return -ENOMEM;
}
-int strv_extend_strv_concat(char ***a, char * const *b, const char *suffix) {
+int strv_extend_strv_biconcat(char ***a, const char *prefix, const char* const *b, const char *suffix) {
int r;
STRV_FOREACH(s, b) {
char *v;
- v = strjoin(*s, suffix);
+ v = strjoin(strempty(prefix), *s, suffix);
if (!v)
return -ENOMEM;
- r = strv_push(a, v);
- if (r < 0) {
- free(v);
+ r = strv_consume(a, v);
+ if (r < 0)
return r;
- }
}
return 0;
diff --git a/src/basic/strv.h b/src/basic/strv.h
index 91337b9287..169737d1d8 100644
--- a/src/basic/strv.h
+++ b/src/basic/strv.h
@@ -43,7 +43,10 @@ int strv_copy_unless_empty(char * const *l, char ***ret);
size_t strv_length(char * const *l) _pure_;
int strv_extend_strv(char ***a, char * const *b, bool filter_duplicates);
-int strv_extend_strv_concat(char ***a, char * const *b, const char *suffix);
+int strv_extend_strv_biconcat(char ***a, const char *prefix, const char* const *b, const char *suffix);
+static inline int strv_extend_strv_concat(char ***a, const char* const *b, const char *suffix) {
+ return strv_extend_strv_biconcat(a, NULL, b, suffix);
+}
int strv_prepend(char ***l, const char *value);
/* _with_size() are lower-level functions where the size can be provided externally,