Skip to content

Commit 1c8effb

Browse files
committed
group1: cpusetController.getValues: don't use naked returns
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 <github@gone.nl>
1 parent d4e976d commit 1c8effb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cgroup1/cpuset.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ func (c *cpusetController) Update(path string, resources *specs.LinuxResources)
8686
}
8787

8888
func (c *cpusetController) getValues(path string) (cpus []byte, mems []byte, err error) {
89-
if cpus, err = os.ReadFile(filepath.Join(path, "cpuset.cpus")); err != nil && !os.IsNotExist(err) {
90-
return
89+
cpus, err = os.ReadFile(filepath.Join(path, "cpuset.cpus"))
90+
if err != nil && !os.IsNotExist(err) {
91+
return nil, nil, err
9192
}
92-
if mems, err = os.ReadFile(filepath.Join(path, "cpuset.mems")); err != nil && !os.IsNotExist(err) {
93-
return
93+
mems, err = os.ReadFile(filepath.Join(path, "cpuset.mems"))
94+
if err != nil && !os.IsNotExist(err) {
95+
return nil, nil, err
9496
}
9597
return cpus, mems, nil
9698
}

0 commit comments

Comments
 (0)