[CRIU] [PATCH 3/3] cg: Merge two equal if-s into one

Pavel Emelyanov xemul at parallels.com
Wed Jul 16 08:49:58 PDT 2014


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>

---
 cgroup.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/cgroup.c b/cgroup.c
index 46dd4b4..31dbc49 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -296,21 +296,19 @@ static int collect_cgroups(struct list_head *ctls)
 		char *name, prefix[] = ".criu.cgmounts.XXXXXX";
 		struct cg_controller *cg;
 
-		if (strstartswith(cc->name, "name="))
+		if (strstartswith(cc->name, "name=")) {
 			name = cc->name + 5;
-		else
+			sprintf(opts, "none,%s", cc->name);
+		} else {
 			name = cc->name;
+			sprintf(opts, "%s", name);
+		}
 
 		if (mkdtemp(prefix) == NULL) {
 			pr_perror("can't make dir for cg mounts\n");
 			return -1;
 		}
 
-		if (name == cc->name)
-			sprintf(opts, "%s", name);
-		else
-			sprintf(opts, "none,%s", cc->name);
-
 		if (mount("none", prefix, "cgroup", 0, opts) < 0) {
 			pr_perror("couldn't mount %s\n", opts);
 			rmdir(prefix);
-- 
1.8.4.2




More information about the CRIU mailing list