-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
/sys/class/power_supply/BAT0/model_name can contain non-utf8 #72
Comments
Hi, @nicklan! This is a great idea, I'm definitely up for this change. Yet, ignoring all potential errors seems to be way too general, instead we should handle only UTF-8 conversion errors and return To do that we can rewrite this function to handle UTF-8 errors separately:
and then use it here: rust-battery/battery/src/platform/linux/sysfs/source.rs Lines 317 to 319 in 575757c
Feel free to write a PR, otherwise I'll see if I can do smth about it later. |
Okay cool. I'm happy to write such a PR. I do wonder though, why only deal with UTF-8 errors? Does not being able to read the model for some other reason really mean not wanting to return ANY battery info? Another suggestion: make the model field itself a I realize that's an API breaking change, so I understand if you'd prefer not to do that. |
As you might have noticed,
Yeah, I'd rather not to change it right now, but your idea is worth to think about :) |
On my system:
Or:
This means trying to get battery info always returns an error due to https://github.com/svartalf/rust-battery/blob/master/battery/src/platform/linux/device.rs#L36
I'd suggest a change to:
I suspect it's a bug in the kernel that this file is basically filled with junk, but it would be nice if the crate didn't totally fail in this case.
The text was updated successfully, but these errors were encountered: