Skip to content

Commit

Permalink
group1: cpusetController.getValues: don't use naked returns
Browse files Browse the repository at this point in the history
Explicitly return nil instead of potentially returning a partial
result (only cpus or mems). Also re-format the code to prevent
these variables being confused for local to the if branch.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Dec 10, 2024
1 parent d4e976d commit 1c8effb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cgroup1/cpuset.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ func (c *cpusetController) Update(path string, resources *specs.LinuxResources)
}

func (c *cpusetController) getValues(path string) (cpus []byte, mems []byte, err error) {
if cpus, err = os.ReadFile(filepath.Join(path, "cpuset.cpus")); err != nil && !os.IsNotExist(err) {
return
cpus, err = os.ReadFile(filepath.Join(path, "cpuset.cpus"))
if err != nil && !os.IsNotExist(err) {
return nil, nil, err
}
if mems, err = os.ReadFile(filepath.Join(path, "cpuset.mems")); err != nil && !os.IsNotExist(err) {
return
mems, err = os.ReadFile(filepath.Join(path, "cpuset.mems"))
if err != nil && !os.IsNotExist(err) {
return nil, nil, err
}
return cpus, mems, nil
}
Expand Down

0 comments on commit 1c8effb

Please sign in to comment.