Skip to content

Commit

Permalink
Merge pull request #9982 from giuseppe/read-cgroups-stats-uint64
Browse files Browse the repository at this point in the history
cgroups: force 64 bits to ParseUint
  • Loading branch information
openshift-merge-robot authored Apr 9, 2021
2 parents 4efac1f + ce74746 commit 54dce00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/cgroups/cgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func readFileAsUint64(path string) (uint64, error) {
if v == "max" {
return math.MaxUint64, nil
}
ret, err := strconv.ParseUint(v, 10, 0)
ret, err := strconv.ParseUint(v, 10, 64)
if err != nil {
return ret, errors.Wrapf(err, "parse %s from %s", v, path)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/cgroups/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func readAcctList(ctr *CgroupControl, name string) ([]uint64, error) {
if s == "" {
break
}
v, err := strconv.ParseUint(s, 10, 0)
v, err := strconv.ParseUint(s, 10, 64)
if err != nil {
return nil, errors.Wrapf(err, "parsing %s", s)
}
Expand Down Expand Up @@ -80,14 +80,14 @@ func (c *cpuHandler) Stat(ctr *CgroupControl, m *Metrics) error {
return err
}
if val, found := values["usage_usec"]; found {
usage.Total, err = strconv.ParseUint(cleanString(val[0]), 10, 0)
usage.Total, err = strconv.ParseUint(cleanString(val[0]), 10, 64)
if err != nil {
return err
}
usage.Kernel *= 1000
}
if val, found := values["system_usec"]; found {
usage.Kernel, err = strconv.ParseUint(cleanString(val[0]), 10, 0)
usage.Kernel, err = strconv.ParseUint(cleanString(val[0]), 10, 64)
if err != nil {
return err
}
Expand Down Expand Up @@ -149,7 +149,7 @@ func GetSystemCPUUsage() (uint64, error) {
}

if val, found := values["usage_usec"]; found {
v, err := strconv.ParseUint(cleanString(val[0]), 10, 0)
v, err := strconv.ParseUint(cleanString(val[0]), 10, 64)
if err != nil {
return 0, err
}
Expand Down

0 comments on commit 54dce00

Please sign in to comment.