aboutsummaryrefslogtreecommitdiff
path: root/modules/devices/battery.c
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@hardinfo.org>2010-08-15 18:36:25 -0300
committerLeandro Pereira <leandro@hardinfo.org>2010-08-15 18:36:25 -0300
commit9fda18663f31e67d8c1c50e1c5a1888abceda2a6 (patch)
treea680bd9c701eaec1016d6beb28bf2c79cfc538e0 /modules/devices/battery.c
parent9fe6a457e1d9d01f6645d91805691afd429d0a2c (diff)
Fix potential problems found by clang static analyzer.
Diffstat (limited to 'modules/devices/battery.c')
-rw-r--r--modules/devices/battery.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/devices/battery.c b/modules/devices/battery.c
index 37416dbb..09c84eeb 100644
--- a/modules/devices/battery.c
+++ b/modules/devices/battery.c
@@ -174,7 +174,10 @@ __scan_battery_acpi(void)
}
if (g_str_equal(present, "yes")) {
- charge_rate = atof(remaining) / atof(capacity);
+ if (remaining && capacity)
+ charge_rate = atof(remaining) / atof(capacity);
+ else
+ charge_rate = 0;
battery_list = h_strdup_cprintf("\n[Battery: %s]\n"
"State=%s (load: %s)\n"