]> err.no Git - systemd/commitdiff
util: more join() optimizations
authorLennart Poettering <lennart@poettering.net>
Mon, 1 Aug 2011 00:45:51 +0000 (02:45 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 1 Aug 2011 00:45:51 +0000 (02:45 +0200)
src/load-dropin.c
src/unit.c

index dbdc6a41df9a35ab09d133721cf60c23296e0d56..eafcc2fdf36ec83c1a2c25dd85057f3dbb926fb5 100644 (file)
@@ -100,10 +100,10 @@ static int process_dir(Unit *u, const char *unit_path, const char *name, const c
                 if (!(template = unit_name_template(name)))
                         return -ENOMEM;
 
-                r = asprintf(&path, "%s/%s%s", unit_path, template, suffix);
+                path = join(unit_path, "/", template, suffix, NULL);
                 free(template);
 
-                if (r < 0)
+                if (!path)
                         return -ENOMEM;
 
                 if (u->meta.manager->unit_path_cache &&
index e494834a6151d7afc9f062ee0f40662b0ada9fa7..65ee0cc35f9abccf0b560e4c5a4cd0f87bb76e9c 100644 (file)
@@ -1772,22 +1772,22 @@ int unit_add_cgroup(Unit *u, CGroupBonding *b) {
 
 static char *default_cgroup_path(Unit *u) {
         char *p;
-        int r;
 
         assert(u);
 
         if (u->meta.instance) {
                 char *t;
 
-                if (!(t = unit_name_template(u->meta.id)))
+                t = unit_name_template(u->meta.id);
+                if (!t)
                         return NULL;
 
-                r = asprintf(&p, "%s/%s/%s", u->meta.manager->cgroup_hierarchy, t, u->meta.instance);
+                p = join(u->meta.manager->cgroup_hierarchy, "/", t, "/", u->meta.instance, NULL);
                 free(t);
         } else
-                r = asprintf(&p, "%s/%s", u->meta.manager->cgroup_hierarchy, u->meta.id);
+                p = join(u->meta.manager->cgroup_hierarchy, "/", u->meta.id, NULL);
 
-        return r < 0 ? NULL : p;
+        return p;
 }
 
 int unit_add_cgroup_from_text(Unit *u, const char *name) {