The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/3064

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From a64edc1c8d5b917180419b7b28a75f50217cbc2f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Thu, 27 Jun 2019 14:25:53 +0200
Subject: [PATCH 1/5] cgroups: use __do_free

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 src/lxc/cgroups/cgfsng.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index 4cf67950ab..bb0c90981f 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -2754,7 +2754,7 @@ __cgfsng_ops static bool cgfsng_data_init(struct 
cgroup_ops *ops)
 
 struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
 {
-       struct cgroup_ops *cgfsng_ops;
+       __do_free struct cgroup_ops *cgfsng_ops = NULL;
 
        cgfsng_ops = malloc(sizeof(struct cgroup_ops));
        if (!cgfsng_ops)
@@ -2763,10 +2763,8 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
        memset(cgfsng_ops, 0, sizeof(struct cgroup_ops));
        cgfsng_ops->cgroup_layout = CGROUP_LAYOUT_UNKNOWN;
 
-       if (!cg_init(cgfsng_ops, conf)) {
-               free(cgfsng_ops);
+       if (!cg_init(cgfsng_ops, conf))
                return NULL;
-       }
 
        cgfsng_ops->data_init = cgfsng_data_init;
        cgfsng_ops->payload_destroy = cgfsng_payload_destroy;
@@ -2790,5 +2788,5 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
        cgfsng_ops->mount = cgfsng_mount;
        cgfsng_ops->nrtasks = cgfsng_nrtasks;
 
-       return cgfsng_ops;
+       return move_ptr(cgfsng_ops);
 }

From 431e2c547f282dbcfac49f81a92fd718698b1806 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Thu, 27 Jun 2019 14:26:14 +0200
Subject: [PATCH 2/5] cgroups: move variables into tighter scope

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 src/lxc/cgroups/cgfsng.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index bb0c90981f..ae2f5dcf93 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -2411,15 +2411,13 @@ __cgfsng_ops static bool cgfsng_setup_limits(struct 
cgroup_ops *ops,
 static bool cgroup_use_wants_controllers(const struct cgroup_ops *ops,
                                       char **controllers)
 {
-       char **cur_ctrl, **cur_use;
-
        if (!ops->cgroup_use)
                return true;
 
-       for (cur_ctrl = controllers; cur_ctrl && *cur_ctrl; cur_ctrl++) {
+       for (char **cur_ctrl = controllers; cur_ctrl && *cur_ctrl; cur_ctrl++) {
                bool found = false;
 
-               for (cur_use = ops->cgroup_use; cur_use && *cur_use; cur_use++) 
{
+               for (char **cur_use = ops->cgroup_use; cur_use && *cur_use; 
cur_use++) {
                        if (strcmp(*cur_use, *cur_ctrl) != 0)
                                continue;
 

From 6280d4c97dd3b72aa2f72cf44b9af888a03052df Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Thu, 27 Jun 2019 14:26:38 +0200
Subject: [PATCH 3/5] cgroups: simplify cgfsng_setup_limits()

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 src/lxc/cgroups/cgfsng.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index ae2f5dcf93..daa2a75d3d 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -2396,13 +2396,10 @@ static bool __cg_unified_setup_limits(struct cgroup_ops 
*ops,
 }
 
 __cgfsng_ops static bool cgfsng_setup_limits(struct cgroup_ops *ops,
-                                              struct lxc_conf *conf,
-                                              bool do_devices)
+                                            struct lxc_conf *conf,
+                                            bool do_devices)
 {
-       bool bret;
-
-       bret = __cg_legacy_setup_limits(ops, &conf->cgroup, do_devices);
-       if (!bret)
+       if (!__cg_legacy_setup_limits(ops, &conf->cgroup, do_devices))
                return false;
 
        return __cg_unified_setup_limits(ops, &conf->cgroup2);

From c05b17bd66142da80ab9031cb19ee8e4441c59e9 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Thu, 27 Jun 2019 14:27:39 +0200
Subject: [PATCH 4/5] cgroups: use __do_free in cgfsng_attach()

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 src/lxc/cgroups/cgfsng.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index daa2a75d3d..b0f90f2229 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -2097,8 +2097,7 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops 
*ops, const char *name,
                return false;
 
        for (i = 0; ops->hierarchies[i]; i++) {
-               __do_free char *path = NULL;
-               char *fullpath = NULL;
+               __do_free char *fullpath = NULL, *path = NULL;
                struct hierarchy *h = ops->hierarchies[i];
 
                if (h->version == CGROUP2_SUPER_MAGIC) {

From 81b5d48a34ef5d20a8795aa322002045cc20b5df Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Thu, 27 Jun 2019 14:27:58 +0200
Subject: [PATCH 5/5] cgroups: move variable into tighter scope

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 src/lxc/cgroups/cgfsng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index b0f90f2229..f29ccd1bcc 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -2086,7 +2086,7 @@ static int __cg_unified_attach(const struct hierarchy *h, 
const char *name,
 __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops *ops, const char 
*name,
                                         const char *lxcpath, pid_t pid)
 {
-       int i, len, ret;
+       int len, ret;
        char pidstr[INTTYPE_TO_STRLEN(pid_t)];
 
        if (!ops->hierarchies)
@@ -2096,7 +2096,7 @@ __cgfsng_ops static bool cgfsng_attach(struct cgroup_ops 
*ops, const char *name,
        if (len < 0 || (size_t)len >= sizeof(pidstr))
                return false;
 
-       for (i = 0; ops->hierarchies[i]; i++) {
+       for (int i = 0; ops->hierarchies[i]; i++) {
                __do_free char *fullpath = NULL, *path = NULL;
                struct hierarchy *h = ops->hierarchies[i];
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to