]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgfsng: cg_legacy_set_data()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 17 Feb 2018 18:47:23 +0000 (19:47 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 21 Feb 2018 16:59:40 +0000 (17:59 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index aa6ca129cb7f7cfbe09214fbc9a2d05dec35681c..a892e7fc782fa99d114e3a9ba0a17c86f1e25542 100644 (file)
@@ -2660,13 +2660,13 @@ out:
        return ret;
 }
 
-/*
- * Called from setup_limits - here we have the container's cgroup_data because
- * we created the cgroups
+/* Called from setup_limits - here we have the container's cgroup_data because
+ * we created the cgroups.
  */
 static int cg_legacy_set_data(const char *filename, const char *value,
                              struct cgfsng_handler_data *d)
 {
+       size_t len;
        char *fullpath, *p;
        /* "b|c <2^64-1>:<2^64-1> r|w|m" = 47 chars max */
        char converted_value[50];
@@ -2674,9 +2674,11 @@ static int cg_legacy_set_data(const char *filename, const char *value,
        int ret = 0;
        char *controller = NULL;
 
-       controller = alloca(strlen(filename) + 1);
+       len = strlen(filename);
+       controller = alloca(len + 1);
        strcpy(controller, filename);
-       if ((p = strchr(controller, '.')) != NULL)
+       p = strchr(controller, '.');
+       if (p)
                *p = '\0';
 
        if (strcmp("devices.allow", filename) == 0 && value[0] == '/') {
@@ -2684,7 +2686,6 @@ static int cg_legacy_set_data(const char *filename, const char *value,
                if (ret < 0)
                        return ret;
                value = converted_value;
-
        }
 
        h = get_hierarchy(controller);
@@ -2694,7 +2695,7 @@ static int cg_legacy_set_data(const char *filename, const char *value,
                      "driver or not enabled on the cgroup hierarchy",
                      controller);
                errno = ENOENT;
-               return -1;
+               return -ENOENT;
        }
 
        fullpath = must_make_path(h->fullcgpath, filename, NULL);