Skip to content

Commit 79cdf11

Browse files
kolyshkinlifubang
authored andcommitted
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 <[email protected]> (cherry picked from commit 12e06a7) Signed-off-by: lfbzhm <[email protected]>
1 parent e01db00 commit 79cdf11

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

libcontainer/cgroups/utils.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,11 @@ func RemovePath(path string) error {
267267
if info.IsDir() {
268268
// We should remove subcgroup first.
269269
if err = RemovePath(filepath.Join(path, info.Name())); err != nil {
270-
break
270+
return err
271271
}
272272
}
273273
}
274-
if err == nil {
275-
err = rmdir(path, true)
276-
}
277-
return err
274+
return rmdir(path, true)
278275
}
279276

280277
// RemovePaths iterates over the provided paths removing them.

0 commit comments

Comments
 (0)