Xinqi Bao's Git

battery_remaining: check for division by zero
authorAaron Marcher <[email protected]>
Sun, 20 May 2018 22:42:06 +0000 (00:42 +0200)
committerAaron Marcher <[email protected]>
Sun, 20 May 2018 22:42:06 +0000 (00:42 +0200)
components/battery.c

index fa525be..8bfe42a 100644 (file)
                                return NULL;
                        }
 
+                       if (current_now == 0) {
+                               return NULL;
+                       }
+
                        timeleft = (double)charge_now / (double)current_now;
                        h = timeleft;
                        m = (timeleft - (double)h) * 60;