From: Aaron Marcher Date: Sun, 20 May 2018 22:42:06 +0000 (+0200) Subject: battery_remaining: check for division by zero X-Git-Url: https://git.atheridis.org/?a=commitdiff_plain;h=aa8654795da19a8d517faf1b84cd4dc4ac75f6e7;p=suckless%2Fslstatus.git battery_remaining: check for division by zero --- diff --git a/components/battery.c b/components/battery.c index fa525be..8bfe42a 100644 --- a/components/battery.c +++ b/components/battery.c @@ -107,6 +107,10 @@ return NULL; } + if (current_now == 0) { + return NULL; + } + timeleft = (double)charge_now / (double)current_now; h = timeleft; m = (timeleft - (double)h) * 60;