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

hwmon: refactor & support lookup of all indices #226

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vmatare
Copy link
Owner

@vmatare vmatare commented Apr 7, 2023

This should allow the user to omit the indices: config field if a sensor input is sufficiently specified by other criteria. In this case, thinkfan should pick up all pwm/temp files found for the given sensor. A major caveat being that the number of available temperature inputs won't be known before a sensors has been successfully looked up...

This should allow the user to omit the indices: config field if a sensor
input is sufficiently specified by other criteria. In this case,
thinkfan should pick up all pwm/temp files found for the given sensor. A
major caveat being that the number of available temperature inputs won't
be known before a sensors has been successfully looked up...
auto subdir = path + "/" + entries[i]->d_name;
free(entries[i]);

for (const filesystem::path &subdir : dir_entries<filter_subdirs>(path)) {

Choose a reason for hiding this comment

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

Suggested change
for (const filesystem::path &subdir : dir_entries<filter_subdirs>(path)) {
for (const auto &subdir : dir_entries<filter_subdirs>(path)) {

and elsewhere in this PR

@@ -231,7 +251,7 @@ string HwmonInterface<HwmonT>::lookup()
if (paths.size() != 1) {
string msg(path + ": ");
if (paths.size() == 0) {
msg += "Could not find a hwmon with this name: " + name_.value();
msg += "Could not find an hwmon with this name: " + name_.value();

Choose a reason for hiding this comment

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

nitpick, hwmon stands for hardware monitor so perhaps it was correct as a. But I'm not a English speaker so not really sure :D

else
found_paths_.push_back(path);
else {
vector<filesystem::path> paths = dir_entries<filter_driver_file>(path);

Choose a reason for hiding this comment

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

Suggested change
vector<filesystem::path> paths = dir_entries<filter_driver_file>(path);
auto paths = dir_entries<filter_driver_file>(path);

found_paths_.push_back(path);
else {
vector<filesystem::path> paths = dir_entries<filter_driver_file>(path);
found_paths_.assign(paths.begin(), paths.end());

Choose a reason for hiding this comment

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

Suggested change
found_paths_.assign(paths.begin(), paths.end());
found_paths_.swap(paths);

Also why don't we assign found_paths_ directly in #285?

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.

None yet

2 participants