[Pkg-wmaker-commits] [wmbattery] 91/241: * Guard some divisions against division by zero. I've never seen that happen and can't reproduce it, but see #454766.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:37:38 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbattery.

commit a985a1e856f3ba08625237ad25c8d67462267f40
Author: Joey Hess <joey at kitenet.net>
Date:   Fri Dec 7 14:56:38 2007 -0500

    * Guard some divisions against division by zero. I've never seen that
      happen and can't reproduce it, but see #454766.
---
 acpi.c           | 7 +++++--
 debian/changelog | 7 +++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/acpi.c b/acpi.c
index 4000614..d665bfe 100644
--- a/acpi.c
+++ b/acpi.c
@@ -362,7 +362,10 @@ int acpi_read (int battery, apm_info *info) {
 				info->battery_status = BATTERY_STATUS_CHARGING;
 				info->ac_line_status = 1;
 				info->battery_flags = info->battery_flags | BATTERY_FLAGS_CHARGING;
-				info->battery_time = -1 * (float) (acpi_batt_capacity[battery] - pcap) / (float) rate * 60;
+				if (rate)
+					info->battery_time = -1 * (float) (acpi_batt_capacity[battery] - pcap) / (float) rate * 60;
+				else
+					info->battery_time = 0;
 				if (abs(info->battery_time) < 0.5)
 					info->battery_time = 0;
 			}
@@ -407,7 +410,7 @@ int acpi_read (int battery, apm_info *info) {
 			find_batteries();
 		}
 		
-		if (pcap) {
+		if (pcap && acpi_batt_capacity[battery]) {
 			/* percentage = (current_capacity / max capacity) * 100 */
 			info->battery_percentage = (float) pcap / (float) acpi_batt_capacity[battery] * 100;
 		}
diff --git a/debian/changelog b/debian/changelog
index a0a76e7..4465de0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+wmbattery (2.32) UNRELEASED; urgency=low
+
+  * Guard some divisions against division by zero. I've never seen that
+    happen and can't reproduce it, but see #454766.
+
+ -- Joey Hess <joeyh at debian.org>  Fri, 07 Dec 2007 14:56:01 -0500
+
 wmbattery (2.31) unstable; urgency=low
 
   * Further fix for my strange battery. If the present capacity is larger

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git



More information about the Pkg-wmaker-commits mailing list