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

BSD platforms: Reject negative and zero KERN_FSCALE factors #1275

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

Explorer09
Copy link
Contributor

The "fscale" value, retrieved by sysctl() in BSD platforms, is used for computing CPU percentages of the processes. To prevent a division by zero, we should reject a zero "fscale" value. (A negative "fscale" value will not make sense either.)

For DragonFlyBSD and FreeBSD, this would fall back to the hard-coded default scale.
For NetBSD and OpenBSD, there is no hard-coded default value, so the zero or negative "fscale" is now a fatal error.

@BenBE BenBE added enhancement Extension or improvement to existing feature code quality ♻️ Code quality enhancement FreeBSD 👹 FreeBSD related issues BSD 🐡 Issues related to *BSD NetBSD 🎏 NetBSD related issues bug 🐛 Something isn't working labels Aug 2, 2023
@BenBE BenBE added this to the 3.3.0 milestone Aug 2, 2023
@Explorer09 Explorer09 force-pushed the bsd-fscale-reject-zero branch 3 times, most recently from 03c517d to a1a8887 Compare August 3, 2023 01:32
@BenBE BenBE added OpenBSD 🐡 OpenBSD related issues DragonflyBSD 🪰 DragonflyBSD related issues and removed BSD 🐡 Issues related to *BSD labels Aug 8, 2023
Copy link
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

The "fscale" value, retrieved by sysctl() in BSD platforms, is used for
computing CPU percentages of the processes. To prevent a division by
zero, we should reject a zero "fscale" value. (A negative "fscale"
value will not make sense either.)

For DragonFlyBSD and FreeBSD, this would fall back to the hard-coded
default scale.
For NetBSD and OpenBSD, there is no hard-coded default value, so the
zero or negative "fscale" is now a fatal error.

Signed-off-by: Kang-Che Sung <[email protected]>
@cgzones cgzones merged commit 4c08171 into htop-dev:main Aug 30, 2023
11 checks passed
@Explorer09 Explorer09 deleted the bsd-fscale-reject-zero branch August 31, 2023 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working code quality ♻️ Code quality enhancement DragonflyBSD 🪰 DragonflyBSD related issues enhancement Extension or improvement to existing feature FreeBSD 👹 FreeBSD related issues NetBSD 🎏 NetBSD related issues OpenBSD 🐡 OpenBSD related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants