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

[BUG] loadvg_linux is wrong #1206

Closed
Dariqq opened this issue Aug 22, 2024 · 8 comments
Closed

[BUG] loadvg_linux is wrong #1206

Dariqq opened this issue Aug 22, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@Dariqq
Copy link
Contributor

Dariqq commented Aug 22, 2024

Hi,

Looking through the loadavg code and in loadavg_linux.c fastfetch seems to read /proc/uptime instead of /proc/loadavg.

Also even if changing to /proc/loadavg (and removing the sysinfo code) the format string sscanf statement seems wrong:

cat /proc/loadavg
2.02 1.44 1.30 3/1633 102474

 ./fastfetch -s loadavg --format json
[
  {
    "type": "Loadavg",
    "result": [
      2.0,
      null,
      null
    ]
  }
]
@Dariqq Dariqq added the bug Something isn't working label Aug 22, 2024
@Dariqq
Copy link
Contributor Author

Dariqq commented Aug 22, 2024

Is the parsing of floats/doubles dependant on locales (whether , or . as seperator)?

@Dariqq
Copy link
Contributor Author

Dariqq commented Aug 22, 2024

It seems to be. If i run with LC_ALL=C the ourput of /proc/loadavg gets parsed correctly but with my default locale it is not

@CarterLi
Copy link
Member

That was awful

@Dariqq
Copy link
Contributor Author

Dariqq commented Aug 22, 2024

this is after dropping the sysinfo call.

LC_ALL=C ./fastfetch -S loadavg --format json
[
  {
    "type": "Loadavg",
    "result": [
      0.41,
      0.48,
      0.54
    ]
  }
]

./fastfetch -S loadavg --format json
[
  {
    "type": "Loadavg",
    "result": [
      0.0,
      null,
      null
    ]
  }
]

@CarterLi
Copy link
Member

This means that every scanf(%f) is buggy

@Dariqq
Copy link
Contributor Author

Dariqq commented Aug 22, 2024

Would it be safe to set LC_NUMERIC=C somewhere in the beginning?

@Dariqq
Copy link
Contributor Author

Dariqq commented Aug 22, 2024

mmh seems to parse string correctly when not using fastfetch

@Dariqq
Copy link
Contributor Author

Dariqq commented Aug 22, 2024

CarterLi added a commit that referenced this issue Aug 23, 2024
CarterLi added a commit to CarterLi/fastfetch that referenced this issue Aug 23, 2024
CarterLi added a commit to CarterLi/fastfetch that referenced this issue Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants