Battery: prevent division by zero
o9000 mrovi9000@gmail.com
1 files changed,
1 insertions(+),
1 deletions(-)
jump to
M
src/battery/linux.c
→
src/battery/linux.c
@@ -286,7 +286,7 @@ gint64 diff_power = ABS(bat->energy_now - old_energy_now);
gint64 diff_time = bat->timestamp - old_timestamp; /* µW = (µWh * 3600) / (µs * 1000000) */ - gint power = diff_power * 3600 * 1000000 / diff_time; + gint power = diff_power * 3600 * 1000000 / MAX(1, diff_time); return power; }