My laptop has a dead battery, voltage is null (zero volt). when printing battery information (which is the default action), it sends back a floating point exception. After tracing the code, "acpi" tries to divide several other value by the voltage value => FPE. My patch sets back the volatge value to -1 (unknown) when 0 was reported. Patch was sent upstream too: http://sourceforge.net/tracker/?func=detail&aid=2892490&group_id=230605&atid=1080677 Reproducible: Always Steps to Reproduce: 1. install a defective battery in your laptop 2. run "acpi" or "acpi -b" Actual Results: floating point exception Expected Results: battery informations
btw, I checked bug #242040 and I confirm it can be closed. sys-power/acpi-1.4 uses my CFLAGS when compiling: # grep CFLAGS /etc/make.conf CFLAGS="-O2 -march=i686 -pipe" CXXFLAGS="${CFLAGS} [...] >>> Compiling source in /var/tmp/portage/sys-power/acpi-1.4-r1/work/acpi-1.4 ... make -j1 make all-am make[1]: Entering directory `/var/tmp/portage/sys-power/acpi-1.4-r1/work/acpi-1.4' i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -Wall -O2 -march=i686 -pipe -c acpi.c i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -Wall -O2 -march=i686 -pipe -c main.c i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -Wall -O2 -march=i686 -pipe -c list.c i686-pc-linux-gnu-gcc -Wall -O2 -march=i686 -pipe -Wl,-O1 -o acpi acpi.o main.o list.o make[1]: Leaving directory `/var/tmp/portage/sys-power/acpi-1.4-r1/work/acpi-1.4' >>> Source compiled. [...]
Created attachment 209306 [details] patch that avoids the FPE here is the patch... ebuild coming too
Created attachment 209308 [details] acpi-1.4-r1.ebuild mostly same as "acpi-1.4.ebuild", except: - added an "inherit" statement for epatch usage - added a src_prepare() section for the patching
btw, the ebuild (sys-power/acpi-1.4-r1) compiles and installs fine. Feel free to place it in portage. Now I get: # acpi -bi Battery 0: Unknown, 0% Battery 0: design capacity 60061 mWh, last full capacity 25290 mWh = 42% which is nicer than the FPE :)
Won't probably matter for this eclass, but EAPI goes always before inherit.
Created attachment 209338 [details] acpi-1.4-r1.ebuild, w/ "EAPI" before "inherit" Updated ebuild. Thanks for the comment.
Created attachment 209405 [details, diff] patch that avoids the FPE
Created attachment 209406 [details] acpi-1.4-r1.ebuild, w/ "EAPI" before "inherits", and typo fixed patch typo corrected, and ebuild updated accordingly.
(In reply to comment #7) > Created an attachment (id=209405) [details] > patch that avoids the FPE > This seems to be fixed in 1.5 with similar looking code, if (!voltage) /* zero voltage makes all calculations mood */ voltage = -1; }