From 92e2175de1e9d7553756219d3ba7ca2996a28cc2 Mon Sep 17 00:00:00 2001 From: zvier Date: Mon, 20 Jul 2020 22:37:36 +0800 Subject: [PATCH] cleancode: clean code for utils_linux.go Signed-off-by: Jeff Zvier --- utils_linux.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/utils_linux.go b/utils_linux.go index a9587f7d..07c8f6ad 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -47,14 +47,13 @@ func loadFactory(context *cli.Context) (libcontainer.Factory, error) { cgroupManager = libcontainer.RootlessCgroupfs } if context.GlobalBool("systemd-cgroup") { - if systemd.IsRunningSystemd() { - cgroupManager = libcontainer.SystemdCgroups - if rootlessCg { - cgroupManager = libcontainer.RootlessSystemdCgroups - } - } else { + if !systemd.IsRunningSystemd() { return nil, errors.New("systemd cgroup flag passed, but systemd support for managing cgroups is not available") } + cgroupManager = libcontainer.SystemdCgroups + if rootlessCg { + cgroupManager = libcontainer.RootlessSystemdCgroups + } } intelRdtManager := libcontainer.IntelRdtFs @@ -423,13 +422,11 @@ func startContainer(context *cli.Context, spec *specs.Spec, action CtAct, criuOp } if notifySocket != nil { - err := notifySocket.setupSocketDirectory() - if err != nil { + if err := notifySocket.setupSocketDirectory(); err != nil { return -1, err } if action == CT_ACT_RUN { - err := notifySocket.bindSocket() - if err != nil { + if err := notifySocket.bindSocket(); err != nil { return -1, err } }