From fea91746a493e466221880e8eb67a78ed3f7980b Mon Sep 17 00:00:00 2001 From: o9000 Date: Sat, 23 Apr 2016 11:54:38 +0200 Subject: [PATCH] Battery: do not show negative durations when the sensors return garbage --- src/battery/linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/battery/linux.c b/src/battery/linux.c index 97f43e7..ef0c036 100644 --- a/src/battery/linux.c +++ b/src/battery/linux.c @@ -437,6 +437,7 @@ int battery_os_update(BatteryState *state) seconds = 3600 * (total_energy_full - total_energy_now) / total_power_now; else if (state->state == BATTERY_DISCHARGING) seconds = 3600 * total_energy_now / total_power_now; + seconds = MAX(0, seconds); } battery_state_set_time(state, seconds);