]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-lookup: path_join() all the things! 16793/head
authorLennart Poettering <lennart@poettering.net>
Wed, 19 Aug 2020 16:27:52 +0000 (18:27 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 19 Aug 2020 16:28:39 +0000 (18:28 +0200)
When we talk about paths, better use path_join(), who knows what callers
pass to us, i.e. prefixed with "/" or not.

src/basic/path-lookup.c

index 52968dee342043348bb029b8fdcedac7b01fff97..3ea851c338547febf4d929fb4adb74e4b0048e75 100644 (file)
@@ -27,7 +27,7 @@ int xdg_user_runtime_dir(char **ret, const char *suffix) {
         if (!e)
                 return -ENXIO;
 
-        j = strjoin(e, suffix);
+        j = path_join(e, suffix);
         if (!j)
                 return -ENOMEM;
 
@@ -44,7 +44,7 @@ int xdg_user_config_dir(char **ret, const char *suffix) {
 
         e = getenv("XDG_CONFIG_HOME");
         if (e)
-                j = strjoin(e, suffix);
+                j = path_join(e, suffix);
         else {
                 _cleanup_free_ char *home = NULL;
 
@@ -52,7 +52,7 @@ int xdg_user_config_dir(char **ret, const char *suffix) {
                 if (r < 0)
                         return r;
 
-                j = strjoin(home, "/.config", suffix);
+                j = path_join(home, "/.config", suffix);
         }
 
         if (!j)
@@ -76,7 +76,7 @@ int xdg_user_data_dir(char **ret, const char *suffix) {
 
         e = getenv("XDG_DATA_HOME");
         if (e)
-                j = strjoin(e, suffix);
+                j = path_join(e, suffix);
         else {
                 _cleanup_free_ char *home = NULL;
 
@@ -84,7 +84,7 @@ int xdg_user_data_dir(char **ret, const char *suffix) {
                 if (r < 0)
                         return r;
 
-                j = strjoin(home, "/.local/share", suffix);
+                j = path_join(home, "/.local/share", suffix);
         }
         if (!j)
                 return -ENOMEM;