Change some data types around to avoid too much conversion.

This commit is contained in:
Renan DelValle 2020-01-04 17:42:59 -08:00
parent 78f533fe21
commit 3d9f92a9c0
No known key found for this signature in database
GPG key ID: 3895800E03F17676

View file

@ -47,7 +47,7 @@ func capNode(base string, percentage int) error {
}
// We use floats to mitigate the possibility of an integer overflows.
powercap := uint(math.Ceil(float64(maxPower) * (float64(percentage) / 100)))
powercap := uint64(math.Ceil(float64(maxPower) * (float64(percentage) / 100)))
err = capZone(filepath.Join(base, file.Name(), powerLimitFileShortWindow), powercap)
if err != nil {
@ -79,8 +79,8 @@ func maxPower(zone string) (uint64, error) {
}
// capZone caps a power zone to a specific amount of watts specified by value
func capZone(zone string, value uint) error {
err := ioutil.WriteFile(zone, []byte(string(value)), 0644)
func capZone(zone string, value uint64) error {
err := ioutil.WriteFile(zone, []byte(strconv.FormatUint(value, 10)), 0644)
if err != nil {
return err
}