Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overflows in battery calculations #607

Closed

Conversation

jiribohac
Copy link
Contributor

commit 52113d9 (fix battery divisions)
actually broke the battery divisions by using int divisions, causing
the following calculations to overflow:
(100 * BATcapacity_remain) / BATcapacity_full

My battery status showed "-19%".
Values read from sysfs:
BATcapacity_remain = 35140000
BATcapacity_full = 39240000

100 * 35140000 overflows the 31 bits of a signed int so the
calculation results in -780967296 / 39240000 = -19.

Force these calculatoins to be long long to avoid the overflow.
The BATtime_remain calculation just barely does not overflow for me but
fix this as well.

commit 52113d9 (fix battery divisions)
actually broke the battery divisions by using int divisions, causing
the following calculations to overflow:
 (100 * BATcapacity_remain) / BATcapacity_full

My battery status showed "-19%".
Values read from sysfs:
BATcapacity_remain = 35140000
BATcapacity_full = 39240000

100 * 35140000 overflows the 31 bits of a signed int so the
calculation results in -780967296 / 39240000 = -19.

Force these calculatoins to be long long to avoid the overflow.
The BATtime_remain calculation just barely does not overflow for me but
fix this as well.
gijsbers added a commit that referenced this pull request Sep 1, 2021
Change defines to enums. Use longs for capacity numbers.
@gijsbers
Copy link
Collaborator

gijsbers commented Sep 1, 2021

Thanks a lot for reporting this! I made some more changes to the APM module.

@gijsbers gijsbers closed this Sep 1, 2021
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Oct 13, 2021
Improve the explanation on how to spy on client messages with icesh.
When rearranging windows with tile placement or cascade placement, correct for
the top side vertical offset, in those themes which have a masked top border.
Improve the explanation for some of the preferences.
Update the winoptions example on DockApps.
Guard against a color name being set to the empty string (bbidulock/icewm#614).
Improve the performance and scalability of the window list menu.
In the window list window group similar application windows together.
Add +group and +Class select options to icesh.
Improve the filtering on the WM_CLASS property in icesh.
Fix the OSS/ALSA defaults in icesound help message (bbidulock/icewm#609).
Fix the OSS/ALSA defaults in icesound man page (bbidulock/icewm#608)
Only support SVG for icons, not for icewmbg backgrounds.
Let icewmbg pixmaps free its associated Image to reduce memory usage.
Prevent a potential trailing -I flag in CMake for issue openembedded#57.
Fix the description for sizeby in the icesh manpage.
Fix overflows in battery calculations for issue bbidulock/icewm#607.
Update the translations, most notably Brazilian Portuguese.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Oct 13, 2021
Improve the explanation on how to spy on client messages with icesh.
When rearranging windows with tile placement or cascade placement, correct for
the top side vertical offset, in those themes which have a masked top border.
Improve the explanation for some of the preferences.
Update the winoptions example on DockApps.
Guard against a color name being set to the empty string (bbidulock/icewm#614).
Improve the performance and scalability of the window list menu.
In the window list window group similar application windows together.
Add +group and +Class select options to icesh.
Improve the filtering on the WM_CLASS property in icesh.
Fix the OSS/ALSA defaults in icesound help message (bbidulock/icewm#609).
Fix the OSS/ALSA defaults in icesound man page (bbidulock/icewm#608)
Only support SVG for icons, not for icewmbg backgrounds.
Let icewmbg pixmaps free its associated Image to reduce memory usage.
Prevent a potential trailing -I flag in CMake for issue openembedded#57.
Fix the description for sizeby in the icesh manpage.
Fix overflows in battery calculations for issue bbidulock/icewm#607.
Update the translations, most notably Brazilian Portuguese.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Oct 14, 2021
Improve the explanation on how to spy on client messages with icesh.
When rearranging windows with tile placement or cascade placement, correct for
the top side vertical offset, in those themes which have a masked top border.
Improve the explanation for some of the preferences.
Update the winoptions example on DockApps.
Guard against a color name being set to the empty string (bbidulock/icewm#614).
Improve the performance and scalability of the window list menu.
In the window list window group similar application windows together.
Add +group and +Class select options to icesh.
Improve the filtering on the WM_CLASS property in icesh.
Fix the OSS/ALSA defaults in icesound help message (bbidulock/icewm#609).
Fix the OSS/ALSA defaults in icesound man page (bbidulock/icewm#608)
Only support SVG for icons, not for icewmbg backgrounds.
Let icewmbg pixmaps free its associated Image to reduce memory usage.
Prevent a potential trailing -I flag in CMake for issue openembedded#57.
Fix the description for sizeby in the icesh manpage.
Fix overflows in battery calculations for issue bbidulock/icewm#607.
Update the translations, most notably Brazilian Portuguese.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Oct 14, 2021
Improve the explanation on how to spy on client messages with icesh.
When rearranging windows with tile placement or cascade placement, correct for
the top side vertical offset, in those themes which have a masked top border.
Improve the explanation for some of the preferences.
Update the winoptions example on DockApps.
Guard against a color name being set to the empty string (bbidulock/icewm#614).
Improve the performance and scalability of the window list menu.
In the window list window group similar application windows together.
Add +group and +Class select options to icesh.
Improve the filtering on the WM_CLASS property in icesh.
Fix the OSS/ALSA defaults in icesound help message (bbidulock/icewm#609).
Fix the OSS/ALSA defaults in icesound man page (bbidulock/icewm#608)
Only support SVG for icons, not for icewmbg backgrounds.
Let icewmbg pixmaps free its associated Image to reduce memory usage.
Prevent a potential trailing -I flag in CMake for issue openembedded#57.
Fix the description for sizeby in the icesh manpage.
Fix overflows in battery calculations for issue bbidulock/icewm#607.
Update the translations, most notably Brazilian Portuguese.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this pull request Oct 16, 2021
Improve the explanation on how to spy on client messages with icesh.
When rearranging windows with tile placement or cascade placement, correct for
the top side vertical offset, in those themes which have a masked top border.
Improve the explanation for some of the preferences.
Update the winoptions example on DockApps.
Guard against a color name being set to the empty string (bbidulock/icewm#614).
Improve the performance and scalability of the window list menu.
In the window list window group similar application windows together.
Add +group and +Class select options to icesh.
Improve the filtering on the WM_CLASS property in icesh.
Fix the OSS/ALSA defaults in icesound help message (bbidulock/icewm#609).
Fix the OSS/ALSA defaults in icesound man page (bbidulock/icewm#608)
Only support SVG for icons, not for icewmbg backgrounds.
Let icewmbg pixmaps free its associated Image to reduce memory usage.
Prevent a potential trailing -I flag in CMake for issue openembedded#57.
Fix the description for sizeby in the icesh manpage.
Fix overflows in battery calculations for issue bbidulock/icewm#607.
Update the translations, most notably Brazilian Portuguese.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request May 22, 2024
Improve the explanation on how to spy on client messages with icesh.
When rearranging windows with tile placement or cascade placement, correct for
the top side vertical offset, in those themes which have a masked top border.
Improve the explanation for some of the preferences.
Update the winoptions example on DockApps.
Guard against a color name being set to the empty string (bbidulock/icewm#614).
Improve the performance and scalability of the window list menu.
In the window list window group similar application windows together.
Add +group and +Class select options to icesh.
Improve the filtering on the WM_CLASS property in icesh.
Fix the OSS/ALSA defaults in icesound help message (bbidulock/icewm#609).
Fix the OSS/ALSA defaults in icesound man page (bbidulock/icewm#608)
Only support SVG for icons, not for icewmbg backgrounds.
Let icewmbg pixmaps free its associated Image to reduce memory usage.
Prevent a potential trailing -I flag in CMake for issue #57.
Fix the description for sizeby in the icesh manpage.
Fix overflows in battery calculations for issue bbidulock/icewm#607.
Update the translations, most notably Brazilian Portuguese.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
daregit pushed a commit to daregit/yocto-combined that referenced this pull request May 22, 2024
Improve the explanation on how to spy on client messages with icesh.
When rearranging windows with tile placement or cascade placement, correct for
the top side vertical offset, in those themes which have a masked top border.
Improve the explanation for some of the preferences.
Update the winoptions example on DockApps.
Guard against a color name being set to the empty string (bbidulock/icewm#614).
Improve the performance and scalability of the window list menu.
In the window list window group similar application windows together.
Add +group and +Class select options to icesh.
Improve the filtering on the WM_CLASS property in icesh.
Fix the OSS/ALSA defaults in icesound help message (bbidulock/icewm#609).
Fix the OSS/ALSA defaults in icesound man page (bbidulock/icewm#608)
Only support SVG for icons, not for icewmbg backgrounds.
Let icewmbg pixmaps free its associated Image to reduce memory usage.
Prevent a potential trailing -I flag in CMake for issue #57.
Fix the description for sizeby in the icesh manpage.
Fix overflows in battery calculations for issue bbidulock/icewm#607.
Update the translations, most notably Brazilian Portuguese.

Signed-off-by: Wang Mingyu <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants