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

Use /etc/hw-release for manufacturer and device name #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

neochapay
Copy link
Contributor

No description provided.

Copy link
Contributor

@spiiroin spiiroin left a 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 Show resolved Hide resolved
// 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);
Copy link
Contributor

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?

src/usb_moded-config.c Show resolved Hide resolved
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);
}
Copy link
Contributor

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.

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.

2 participants