diff options
author | Bastien Nocera <hadess@hadess.net> | 2023-04-15 12:24:18 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2023-04-15 13:17:46 +0200 |
commit | b773285d5efaa03f5ef536bb5472b7ce41b237d3 (patch) | |
tree | 0709d4792a6bd58a258f0e7f2223e482cc627fe6 | |
parent | 5db1bce65fcd509a7624dc2843173921b79e7d7b (diff) | |
download | upower-b773285d5efaa03f5ef536bb5472b7ce41b237d3.tar.gz |
battery: Fix power rate checks for amount < 1W
Fix the power rate check, energy_rate is a float, and abs() handles ints,
so any rate under 1W would have been truncated to 0.
-rw-r--r-- | src/up-device-battery.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/up-device-battery.c b/src/up-device-battery.c index 734b6a8..c814d9f 100644 --- a/src/up-device-battery.c +++ b/src/up-device-battery.c @@ -155,7 +155,7 @@ up_device_battery_estimate_power (UpDeviceBattery *self, UpBatteryValues *cur) */ if (cur->state == UP_DEVICE_STATE_UNKNOWN) { /* Consider a rate of 0.5W as "no change", otherwise set CHARGING/DISCHARGING */ - if (abs(energy_rate) < 0.5) + if (ABS(energy_rate) < 0.5) return; else if (energy_rate < 0.0) cur->state = UP_DEVICE_STATE_DISCHARGING; |