From 12e06a7c4f081fc6fb4347741bf054f7ee7c256b Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 11 Nov 2024 23:13:27 -0800 Subject: [PATCH] libct/cg: RemovePath: simplify logic If the sub-cgroup RemovePath has failed for any reason, return the error right away. This way, we don't have to check for err != nil before retrying rmdir. This is a cosmetic change and should not change any functionality. Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/utils.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libcontainer/cgroups/utils.go b/libcontainer/cgroups/utils.go index f699ed709..e36058565 100644 --- a/libcontainer/cgroups/utils.go +++ b/libcontainer/cgroups/utils.go @@ -267,14 +267,11 @@ func RemovePath(path string) error { if info.IsDir() { // We should remove subcgroup first. if err = RemovePath(filepath.Join(path, info.Name())); err != nil { - break + return err } } } - if err == nil { - err = rmdir(path, true) - } - return err + return rmdir(path, true) } // RemovePaths iterates over the provided paths removing them.