Skip to content

Commit

Permalink
libotutil: Allow missing groups when getting key values with default
Browse files Browse the repository at this point in the history
Prep commit as part of ostreedev#1814, where a new `sysroot` group is added
to the repo config. This allows falling back to a default key value
if the specified group does not exist in the config file.
  • Loading branch information
Robert Fairley committed Feb 15, 2019
1 parent ed63396 commit bd082ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/libotutil/ot-keyfile-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ ot_keyfile_get_boolean_with_default (GKeyFile *keyfile,
ret_bool = g_key_file_get_boolean (keyfile, section, value, &temp_error);
if (temp_error)
{
if (g_error_matches (temp_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
if (g_error_matches (temp_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)
|| g_error_matches (temp_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
{
g_clear_error (&temp_error);
ret_bool = default_value;
Expand Down Expand Up @@ -83,7 +84,8 @@ ot_keyfile_get_value_with_default (GKeyFile *keyfile,
ret_value = g_key_file_get_value (keyfile, section, value, &temp_error);
if (temp_error)
{
if (g_error_matches (temp_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
if (g_error_matches (temp_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)
|| g_error_matches (temp_error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND))
{
g_clear_error (&temp_error);
ret_value = g_strdup (default_value);
Expand Down

0 comments on commit bd082ad

Please sign in to comment.