diff options
Diffstat (limited to 'pkg/cgroups')
-rw-r--r-- | pkg/cgroups/cgroups.go | 4 | ||||
-rw-r--r-- | pkg/cgroups/cpu.go | 3 |
2 files changed, 3 insertions, 4 deletions
diff --git a/pkg/cgroups/cgroups.go b/pkg/cgroups/cgroups.go index 3b56f944f..399072108 100644 --- a/pkg/cgroups/cgroups.go +++ b/pkg/cgroups/cgroups.go @@ -133,7 +133,7 @@ func getAvailableControllers(exclude map[string]controllerHandler, cgroup2 bool) if err != nil { return nil, errors.Wrapf(err, "read directory %s", cgroupRoot) } - var controllers []controller + controllers := []controller{} for _, i := range infos { name := i.Name() if _, found := exclude[name]; found { @@ -505,7 +505,7 @@ func (c *CgroupControl) AddPid(pid int) error { return nil } - var names []string + names := make([]string, 0, len(handlers)) for n := range handlers { names = append(names, n) } diff --git a/pkg/cgroups/cpu.go b/pkg/cgroups/cpu.go index 5f0a18031..3745c6e50 100644 --- a/pkg/cgroups/cpu.go +++ b/pkg/cgroups/cpu.go @@ -29,13 +29,12 @@ func readAcct(ctr *CgroupControl, name string) (uint64, error) { } func readAcctList(ctr *CgroupControl, name string) ([]uint64, error) { - var r []uint64 - p := filepath.Join(ctr.getCgroupv1Path(CPUAcct), name) data, err := ioutil.ReadFile(p) if err != nil { return nil, errors.Wrapf(err, "reading %s", p) } + r := []uint64{} for _, s := range strings.Split(string(data), " ") { s = cleanString(s) if s == "" { |