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

Treat core_count as integer #225

Closed
wants to merge 1 commit into from
Closed

Treat core_count as integer #225

wants to merge 1 commit into from

Conversation

yubiuser
Copy link
Member

Thank you for your contribution to the Pi-hole Community!

Please read the comments below to help us consider your Pull Request.

We are all volunteers and completing the process outlined will help us review your commits quicker.

Please make sure you

  1. Base your code and PRs against the repositories developmental branch.
  2. Sign Off all commits as we enforce the DCO for all contributions

  • What does this PR aim to accomplish?:

Fixes #224.

PR #212 removed the declare -i core_count because declare is not supported by POSIX. However, later we do an arithmetic +1 to core_count which will not be interpreted as addition but results in something like 255+1. This is not a visible issue, unless cat /sys/devices/system/cpu/kernel_max returns 0 which leads to the issue seen in #224 (division by zero resulting in inf by awk)

  • How does this PR accomplish the above?:

Use $(( )) syntax to do arithmetic expansion.


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code and I have tested my changes.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

[x] I have read the above and my PR is ready for review. Check this box to confirm

Signed-off-by: Christian König <ckoenig@posteo.de>
@yubiuser yubiuser linked an issue May 26, 2022 that may be closed by this pull request
@dschaper
Copy link
Member

Was there a reason for that sysfs file being the one? Or it's what was there before.

$ cat /sys/devices/system/cpu/possible
0-31

$ cat /sys/devices/system/cpu/present
0-15

$ cat /sys/devices/system/cpu/online
0-15

$ cat /sys/devices/system/cpu/offline 
16-31

From https://unix.stackexchange.com/questions/609555/how-does-linux-detect-number-of-possible-cpus

@rdwebdesign
Copy link
Member

Was there a reason for that sysfs file being the one? Or it's what was there before.

It was this file for the last 4 years:
https://github.com/pi-hole/PADD/blame/ca45bbda551107b6a4c4a88aed5d9a7513942cef/padd.sh#L25

Introduced here: #37

@dschaper
Copy link
Member

What does /sys/devices/system/cpu/kernel_max show on the RPi? I think it's almost always going to be 255.

@yubiuser
Copy link
Member Author

Alternative proposal: #227

@yubiuser
Copy link
Member Author

Closing this as #227 has been merged.

@yubiuser yubiuser closed this May 31, 2022
@yubiuser yubiuser deleted the fix/core_count branch May 31, 2022 21:06
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.

Illegal number: inf / Pi-Hole versions not showing
3 participants