]> Dogcows Code - chaz/tint2/commitdiff
fixed possible segfault
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 16 May 2009 15:43:48 +0000 (15:43 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 16 May 2009 15:43:48 +0000 (15:43 +0000)
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.026227 seconds and 4 git commands to generate.