X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fpath-util.c;h=0b50ea646aa984a3a1a64b15946f438ac17527e1;hb=95f1b47d27066c139ca685f65a2e4e91e1c3d6a9;hp=4857971b33002f29b496f6292a380d742c069b28;hpb=874310b7b68c4c0d36ff07397db30a959bb7dae5;p=elogind.git diff --git a/src/shared/path-util.c b/src/shared/path-util.c index 4857971b3..0b50ea646 100644 --- a/src/shared/path-util.c +++ b/src/shared/path-util.c @@ -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,7 +191,6 @@ char **path_strv_canonicalize(char **l) { errno = 0; u = canonicalize_file_name(t); - if (!u) { if (errno == ENOENT) u = t; @@ -201,7 +201,8 @@ char **path_strv_canonicalize(char **l) { continue; } - } + } else + free(t); l[k++] = u; } @@ -214,24 +215,14 @@ char **path_strv_canonicalize(char **l) { return l; } -char **path_strv_remove_empty(char **l) { - char **f, **t; +char **path_strv_canonicalize_uniq(char **l) { + if (strv_isempty(l)) + return l; - if (!l) + if (!path_strv_canonicalize(l)) return NULL; - for (f = t = l; *f; f++) { - - if (dir_is_empty(*f) > 0) { - free(*f); - continue; - } - - *(t++) = *f; - } - - *t = NULL; - return l; + return strv_uniq(l); } char *path_kill_slashes(char *path) {