summaryrefslogtreecommitdiffstats
path: root/src/basic/unit-name.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2015-07-29 20:25:57 +0200
committerDaniel Mack <daniel@zonque.org>2015-07-30 13:09:01 +0200
commit2fc09a9cdd1ad25bc7c53a23d5301eb952e1ce3d (patch)
treec662c5bf209dae93822ac07a831882a7ba4ba0b2 /src/basic/unit-name.c
parentMerge pull request #783 from whot/hwdb-updates (diff)
downloadsystemd-2fc09a9cdd1ad25bc7c53a23d5301eb952e1ce3d.tar.xz
systemd-2fc09a9cdd1ad25bc7c53a23d5301eb952e1ce3d.zip
tree-wide: use free_and_strdup()
Use free_and_strdup() where appropriate and replace equivalent, open-coded versions.
Diffstat (limited to 'src/basic/unit-name.c')
-rw-r--r--src/basic/unit-name.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c
index bf52463d81..4b84542d0c 100644
--- a/src/basic/unit-name.c
+++ b/src/basic/unit-name.c
@@ -673,6 +673,7 @@ int unit_name_mangle_with_suffix(const char *name, UnitNameMangle allow_globs, c
int slice_build_parent_slice(const char *slice, char **ret) {
char *s, *dash;
+ int r;
assert(slice);
assert(ret);
@@ -693,11 +694,9 @@ int slice_build_parent_slice(const char *slice, char **ret) {
if (dash)
strcpy(dash, ".slice");
else {
- free(s);
-
- s = strdup("-.slice");
- if (!s)
- return -ENOMEM;
+ r = free_and_strdup(&s, "-.slice");
+ if (r < 0)
+ return r;
}
*ret = s;