chiark / gitweb /
python-systemd: rename Journal to Reader
[elogind.git] / src / core / cgroup-attr.c
index cedf37de501dab7c5f64b2abe669c1eb93b21fc1..1373684bdb08a3029b2d2f03eed4a42c539bee03 100644 (file)
 #include "cgroup-attr.h"
 #include "cgroup-util.h"
 #include "list.h"
+#include "fileio.h"
 
 int cgroup_attribute_apply(CGroupAttribute *a, CGroupBonding *b) {
         int r;
-        char *path = NULL;
-        char *v = NULL;
+        _cleanup_free_ char *path = NULL, *v = NULL;
 
         assert(a);
 
@@ -41,18 +41,13 @@ int cgroup_attribute_apply(CGroupAttribute *a, CGroupBonding *b) {
         }
 
         r = cg_get_path(a->controller, b->path, a->name, &path);
-        if (r < 0) {
-                free(v);
+        if (r < 0)
                 return r;
-        }
 
         r = write_one_line_file(path, v ? v : a->value);
         if (r < 0)
                 log_warning("Failed to write '%s' to %s: %s", v ? v : a->value, path, strerror(-r));
 
-        free(path);
-        free(v);
-
         return r;
 }