diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-03-06 04:04:58 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-03-06 05:04:51 +0100 |
commit | 58d081428af6f49c601619c2ee9f9aae24d05fae (patch) | |
tree | d501a34233b42f3cdb208ce2685bc5c60776f6f1 /src/shared/unit-name.c | |
parent | cryptsetup: some fixes (diff) | |
download | systemd-58d081428af6f49c601619c2ee9f9aae24d05fae.tar.xz systemd-58d081428af6f49c601619c2ee9f9aae24d05fae.zip |
unit-name: modernizations
Diffstat (limited to '')
-rw-r--r-- | src/shared/unit-name.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c index 2924c473df..e9b0636143 100644 --- a/src/shared/unit-name.c +++ b/src/shared/unit-name.c @@ -294,7 +294,7 @@ char *unit_name_unescape(const char *f) { } char *unit_name_path_escape(const char *f) { - char *p, *e; + _cleanup_free_ char *p; assert(f); @@ -304,15 +304,10 @@ char *unit_name_path_escape(const char *f) { path_kill_slashes(p); - if (streq(p, "/") || streq(p, "")) { - free(p); + if (streq(p, "/") || streq(p, "")) return strdup("-"); - } - - e = unit_name_escape(p[0] == '/' ? p + 1 : p); - free(p); - return e; + return unit_name_escape(p[0] == '/' ? p + 1 : p); } char *unit_name_path_unescape(const char *f) { @@ -410,7 +405,7 @@ char *unit_name_template(const char *f) { } char *unit_name_from_path(const char *path, const char *suffix) { - char *p, *r; + _cleanup_free_ char *p = NULL; assert(path); assert(suffix); @@ -419,14 +414,11 @@ char *unit_name_from_path(const char *path, const char *suffix) { if (!p) return NULL; - r = strappend(p, suffix); - free(p); - - return r; + return strappend(p, suffix); } char *unit_name_from_path_instance(const char *prefix, const char *path, const char *suffix) { - char *p, *r; + _cleanup_free_ char *p = NULL; assert(prefix); assert(path); @@ -436,10 +428,7 @@ char *unit_name_from_path_instance(const char *prefix, const char *path, const c if (!p) return NULL; - r = strjoin(prefix, "@", p, suffix, NULL); - free(p); - - return r; + return strjoin(prefix, "@", p, suffix, NULL); } char *unit_name_to_path(const char *name) { |