Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 291956 - sys-power/acpi-1.4 gives floating point exception when battery voltage is null - ebuild and patch provided
Summary: sys-power/acpi-1.4 gives floating point exception when battery voltage is nul...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Mobile Herd (OBSOLETE)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-05 10:24 UTC by po.valles
Modified: 2010-04-28 08:28 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch that avoids the FPE (volatge_zero_FPE.patch,346 bytes, text/plain)
2009-11-05 10:28 UTC, po.valles
Details
acpi-1.4-r1.ebuild (acpi-1.4-r1.ebuild,718 bytes, text/plain)
2009-11-05 10:30 UTC, po.valles
Details
acpi-1.4-r1.ebuild, w/ "EAPI" before "inherit" (acpi-1.4-r1.ebuild,718 bytes, text/plain)
2009-11-05 14:30 UTC, po.valles
Details
patch that avoids the FPE (voltage_zero_FPE.patch,346 bytes, patch)
2009-11-06 11:04 UTC, po.valles
Details | Diff
acpi-1.4-r1.ebuild, w/ "EAPI" before "inherits", and typo fixed (acpi-1.4-r1.ebuild,718 bytes, text/plain)
2009-11-06 11:06 UTC, po.valles
Details

Note You need to log in before you can comment on or make changes to this bug.
Description po.valles 2009-11-05 10:24:09 UTC
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
Comment 1 po.valles 2009-11-05 10:27:20 UTC
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.
[...]
Comment 2 po.valles 2009-11-05 10:28:28 UTC
Created attachment 209306 [details]
patch that avoids the FPE

here is the patch... ebuild coming too
Comment 3 po.valles 2009-11-05 10:30:36 UTC
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
Comment 4 po.valles 2009-11-05 10:44:11 UTC
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 :)
Comment 5 Rafał Mużyło 2009-11-05 13:59:18 UTC
Won't probably matter for this eclass,
but EAPI goes always before inherit.
Comment 6 po.valles 2009-11-05 14:30:12 UTC
Created attachment 209338 [details]
acpi-1.4-r1.ebuild, w/ "EAPI" before "inherit"

Updated ebuild. Thanks for the comment.
Comment 7 po.valles 2009-11-06 11:04:33 UTC
Created attachment 209405 [details, diff]
patch that avoids the FPE
Comment 8 po.valles 2009-11-06 11:06:09 UTC
Created attachment 209406 [details]
acpi-1.4-r1.ebuild, w/ "EAPI" before "inherits", and typo fixed

patch typo corrected, and ebuild updated accordingly.
Comment 9 Samuli Suominen (RETIRED) gentoo-dev 2010-04-28 08:28:39 UTC
(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;
}