-
Notifications
You must be signed in to change notification settings - Fork 10
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
Use /etc/hw-release for manufacturer and device name #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some doubts about whether g_key_file_xxx() functions can be used for parsing /etc/hw-release files that are not of ini-file format.
Also, the commit message could have a bit more content. Like what kind of keys (and format?) are expected.
src/usb_moded-config.c
Outdated
// Create a new GKeyFile object and a bitwise list of flags. | ||
hwReleaseFile = g_key_file_new(); | ||
if (g_key_file_load_from_file(hwReleaseFile, "/etc/hw-release", G_KEY_FILE_NONE, &error)) { | ||
return g_key_file_get_string(hwReleaseFile, NULL, "MANUFACTURER", NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually work?
Documentation does not explicitly allow passing NULL group_name.
Code has: g_return_val_if_fail (group_name != NULL, NULL);
Which would indicate that passing null group name is considered an programming error -> some diagnostic logging and NULL return value.
Also, to still allow fallback to config_get_conf_string() below, this should probably return from here only if non-null result was obtained from key file query?
hwReleaseFile = g_key_file_new(); | ||
if (g_key_file_load_from_file(hwReleaseFile, "/etc/hw-release", G_KEY_FILE_NONE, &error)) { | ||
return g_key_file_get_string(hwReleaseFile, NULL, "NAME", NULL); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a (local) helper function might improve readability vs. verbatim code duplication. Especially if it turns out that g_key_file_xxx() can't be used for this purpose and a custom parser needs to be written.
No description provided.