]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libsystemd/sd-path/sd-path.c
tree-wide: replace strjoin() with path_join()
[thirdparty/systemd.git] / src / libsystemd / sd-path / sd-path.c
index d590c90f2e62ee9d777de80d2a65be11ac26d833..5b6bff1139a6fd3a52ca87059bd32000a0f60ed8 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "alloc-util.h"
 #include "architecture.h"
-#include "def.h"
 #include "fd-util.h"
 #include "fileio.h"
 #include "fs-util.h"
@@ -59,10 +58,7 @@ static int from_home_dir(const char *envname, const char *suffix, char **buffer,
         if (r < 0)
                 return r;
 
-        if (endswith(h, "/"))
-                cc = strappend(h, suffix);
-        else
-                cc = strjoin(h, "/", suffix);
+        cc = path_join(h, suffix);
         if (!cc)
                 return -ENOMEM;
 
@@ -375,11 +371,7 @@ _public_ int sd_path_home(uint64_t type, const char *suffix, char **path) {
         }
 
         suffix += strspn(suffix, "/");
-
-        if (endswith(ret, "/"))
-                cc = strappend(ret, suffix);
-        else
-                cc = strjoin(ret, "/", suffix);
+        cc = path_join(ret, suffix);
 
         free(buffer);
 
@@ -444,10 +436,7 @@ static int search_from_environment(
         if (!h && home_suffix) {
                 e = secure_getenv("HOME");
                 if (e && path_is_absolute(e)) {
-                        if (endswith(e, "/"))
-                                h = strappend(e, home_suffix);
-                        else
-                                h = strjoin(e, "/", home_suffix);
+                        h = path_join(e, home_suffix);
 
                         if (!h) {
                                 strv_free(l);
@@ -622,12 +611,7 @@ _public_ int sd_path_search(uint64_t type, const char *suffix, char ***paths) {
 
         j = n;
         STRV_FOREACH(i, l) {
-
-                if (endswith(*i, "/"))
-                        *j = strappend(*i, suffix);
-                else
-                        *j = strjoin(*i, "/", suffix);
-
+                *j = path_join(*i, suffix);
                 if (!*j)
                         return -ENOMEM;