[hackers] [slstatus] battery_remaining: check for division by zero || Aaron Marcher
commit aa8654795da19a8d517faf1b84cd4dc4ac75f6e7
Author: Aaron Marcher <me_AT_drkhsh.at>
AuthorDate: Mon May 21 00:42:06 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Mon May 21 00:42:06 2018 +0200
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
_AT_@ -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;
Received on Mon May 21 2018 - 00:42:24 CEST
This archive was generated by hypermail 2.3.0
: Mon May 21 2018 - 00:48:34 CEST