chiark / gitweb /
efi: fix returned length of efi_get_variable()
[elogind.git] / src / shared / path-util.c
index dd12d3d63409654fb446028ba92a0860bc83e4c1..52ce65de6d9a8b8e65f6a533ab896c317129c628 100644 (file)
@@ -135,7 +135,8 @@ char *path_make_absolute_cwd(const char *p) {
         if (path_is_absolute(p))
                 return strdup(p);
 
-        if (!(cwd = get_current_dir_name()))
+        cwd = get_current_dir_name();
+        if (!cwd)
                 return NULL;
 
         r = path_make_absolute(p, cwd);
@@ -190,14 +191,18 @@ char **path_strv_canonicalize(char **l) {
 
                 errno = 0;
                 u = canonicalize_file_name(t);
-                free(t);
-
                 if (!u) {
-                        if (errno == ENOMEM || !errno)
-                                enomem = true;
-
-                        continue;
-                }
+                        if (errno == ENOENT)
+                                u = t;
+                        else {
+                                free(t);
+                                if (errno == ENOMEM || !errno)
+                                        enomem = true;
+
+                                continue;
+                        }
+                } else
+                        free(t);
 
                 l[k++] = u;
         }
@@ -210,26 +215,6 @@ char **path_strv_canonicalize(char **l) {
         return l;
 }
 
-char **path_strv_remove_empty(char **l) {
-        char **f, **t;
-
-        if (!l)
-                return NULL;
-
-        for (f = t = l; *f; f++) {
-
-                if (dir_is_empty(*f) > 0) {
-                        free(*f);
-                        continue;
-                }
-
-                *(t++) = *f;
-        }
-
-        *t = NULL;
-        return l;
-}
-
 char *path_kill_slashes(char *path) {
         char *f, *t;
         bool slash = false;