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 <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2024-11-11 23:13:27 -08:00
parent db59489b68
commit 12e06a7c4f
+2 -5
View File
@@ -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.