summaryrefslogtreecommitdiff
path: root/pkg/cgroups/cpu.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2021-04-09 10:07:46 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2021-04-09 10:09:54 +0200
commitce747466a9ec44b97dac96ab39c31e06ae761fde (patch)
tree1ce3c8399cc34dcf4c83955bd3f27ea997baed27 /pkg/cgroups/cpu.go
parent4efac1f76012c35122bca7c8feebc33141fc47d3 (diff)
downloadpodman-ce747466a9ec44b97dac96ab39c31e06ae761fde.tar.gz
podman-ce747466a9ec44b97dac96ab39c31e06ae761fde.tar.bz2
podman-ce747466a9ec44b97dac96ab39c31e06ae761fde.zip
cgroups: force 64 bits to ParseUint
[NO TESTS NEEDED] force bitsSize==64 so that the string is always parsed to a uint64 instead of using the native int size, that could be not big enough on 32 bits arches. Closes: https://github.com/containers/podman/issues/9979 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/cgroups/cpu.go')
-rw-r--r--pkg/cgroups/cpu.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/cgroups/cpu.go b/pkg/cgroups/cpu.go
index 05223c2e1..23539757d 100644
--- a/pkg/cgroups/cpu.go
+++ b/pkg/cgroups/cpu.go
@@ -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)
}
@@ -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
}
@@ -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
}