Skip to content

Commit

Permalink
libct/cg: RemovePath: simplify logic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kolyshkin committed Nov 12, 2024
1 parent db59489 commit 12e06a7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions libcontainer/cgroups/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 12e06a7

Please sign in to comment.