diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-07-11 19:14:16 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-07-12 07:31:12 +0200 |
commit | b910cc72c0fb56d96bf98704450fba1f339d8527 (patch) | |
tree | c36280c1d426b1ec859ecb55872314d6a9855f35 /src/basic/unit-name.c | |
parent | Merge pull request #12971 from yuwata/network-reassign-static-routes (diff) | |
download | systemd-b910cc72c0fb56d96bf98704450fba1f339d8527.tar.xz systemd-b910cc72c0fb56d96bf98704450fba1f339d8527.zip |
tree-wide: get rid of strappend()
It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
Diffstat (limited to 'src/basic/unit-name.c')
-rw-r--r-- | src/basic/unit-name.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c index 1b81fe268f..af873d0ffd 100644 --- a/src/basic/unit-name.c +++ b/src/basic/unit-name.c @@ -402,7 +402,7 @@ int unit_name_path_escape(const char *f, char **ret) { } int unit_name_path_unescape(const char *f, char **ret) { - char *s; + _cleanup_free_ char *s = NULL; int r; assert(f); @@ -415,34 +415,27 @@ int unit_name_path_unescape(const char *f, char **ret) { if (!s) return -ENOMEM; } else { - char *w; + _cleanup_free_ char *w = NULL; r = unit_name_unescape(f, &w); if (r < 0) return r; /* Don't accept trailing or leading slashes */ - if (startswith(w, "/") || endswith(w, "/")) { - free(w); + if (startswith(w, "/") || endswith(w, "/")) return -EINVAL; - } /* Prefix a slash again */ - s = strappend("/", w); - free(w); + s = strjoin("/", w); if (!s) return -ENOMEM; - if (!path_is_normalized(s)) { - free(s); + if (!path_is_normalized(s)) return -EINVAL; - } } if (ret) - *ret = s; - else - free(s); + *ret = TAKE_PTR(s); return 0; } @@ -519,7 +512,7 @@ int unit_name_from_path(const char *path, const char *suffix, char **ret) { if (r < 0) return r; - s = strappend(p, suffix); + s = strjoin(p, suffix); if (!s) return -ENOMEM; @@ -719,7 +712,7 @@ int slice_build_subslice(const char *slice, const char *name, char **ret) { return -EINVAL; if (streq(slice, SPECIAL_ROOT_SLICE)) - subslice = strappend(name, ".slice"); + subslice = strjoin(name, ".slice"); else { char *e; |