chiark / gitweb /
Prep v225: Applying various fixes and changes to src/basic that got lost during git...
[elogind.git] / src / basic / unit-name.c
index 5dac442b1b110fb132ac5ddc5bcd61a1fceaf6f4..f8965262c1130c806250532d44160554214fa247 100644 (file)
@@ -687,6 +687,7 @@ int unit_name_mangle_with_suffix(const char *name, UnitNameMangle allow_globs, c
 #if 0
 int slice_build_parent_slice(const char *slice, char **ret) {
         char *s, *dash;
+        int r;
 
         assert(slice);
         assert(ret);
@@ -707,11 +708,11 @@ int slice_build_parent_slice(const char *slice, char **ret) {
         if (dash)
                 strcpy(dash, ".slice");
         else {
+                r = free_and_strdup(&s, "-.slice");
+                if (r < 0) {
                 free(s);
-
-                s = strdup("-.slice");
-                if (!s)
-                        return -ENOMEM;
+                        return r;
+                }
         }
 
         *ret = s;