]> Dogcows Code - chaz/tint2/blobdiff - src/battery/battery.c
fixed possible segfault
[chaz/tint2] / src / battery / battery.c
index 7bd6f949fff415443c6ddce98541e1b64c67a70a..6a6877e45d5f1b05c2afd270c4ddf9509ff94f3e 100644 (file)
@@ -100,7 +100,8 @@ void update_battery(struct batstate *data) {
        seconds -= 60 * data->time.minutes;
        data->time.seconds = seconds;
 
-       new_percentage = (energy_now*100)/energy_full;
+       if(energy_full > 0)
+               new_percentage = (energy_now*100)/energy_full;
 
        if(battery_low_status != 0 && battery_low_status == new_percentage && data->percentage > new_percentage) {
                printf("battery low, executing: %s\n", battery_low_cmd);
This page took 0.019802 seconds and 4 git commands to generate.