battery_remaining: check for division by zero
Aaron Marcher me@drkhsh.at
Mon, 21 May 2018 00:42:06 +0200
1 files changed,
4 insertions(+),
0 deletions(-)
jump to
M
components/battery.c
→
components/battery.c
@@ -107,6 +107,10 @@ pscanf(path, "%d", ¤t_now) < 0) {
return NULL; } + if (current_now == 0) { + return NULL; + } + timeleft = (double)charge_now / (double)current_now; h = timeleft; m = (timeleft - (double)h) * 60;