Author: dumbbell Date: Sat Nov 26 13:43:50 2011 New Revision: 227992 URL: http://svn.freebsd.org/changeset/base/227992
Log: Prevent a division by zero with some broken batteries This problem was seen on a laptop with a dead battery. Modified: head/sys/dev/acpica/acpi_battery.c Modified: head/sys/dev/acpica/acpi_battery.c ============================================================================== --- head/sys/dev/acpica/acpi_battery.c Sat Nov 26 08:23:25 2011 (r227991) +++ head/sys/dev/acpica/acpi_battery.c Sat Nov 26 13:43:50 2011 (r227992) @@ -205,6 +205,14 @@ acpi_battery_get_battinfo(device_t dev, bif->lfcap = (bif->lfcap * bif->dvol) / 1000; } + /* + * The calculation above may set bif->lfcap to zero. This was + * seen on a laptop with a broken battery. The result of the + * division was rounded to zero. + */ + if (!acpi_battery_bif_valid(bif)) + continue; + /* Calculate percent capacity remaining. */ bi[i].cap = (100 * bst[i].cap) / bif->lfcap; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"