config: get rid of @error argument to nm_config_data_get_value()

We don't use this argument. A failure to retrieve a key is (for
every practical purpose) the same as no such key.

(cherry picked from commit a5f7abb842)
This commit is contained in:
Thomas Haller 2015-06-09 08:17:28 +02:00
parent b1246efc60
commit 4ba8dd09ac
5 changed files with 25 additions and 37 deletions

View file

@ -107,11 +107,13 @@ nm_config_data_get_config_description (const NMConfigData *self)
}
char *
nm_config_data_get_value (const NMConfigData *self, const char *group, const char *key, GError **error)
nm_config_data_get_value (const NMConfigData *self, const char *group, const char *key)
{
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (group && *group, NULL);
g_return_val_if_fail (key && *key, NULL);
return g_key_file_get_string (NM_CONFIG_DATA_GET_PRIVATE (self)->keyfile, group, key, error);
return g_key_file_get_string (NM_CONFIG_DATA_GET_PRIVATE (self)->keyfile, group, key, NULL);
}
const char *

View file

@ -83,7 +83,7 @@ NMConfigChangeFlags nm_config_data_diff (NMConfigData *old_data, NMConfigData *n
const char *nm_config_data_get_config_main_file (const NMConfigData *config_data);
const char *nm_config_data_get_config_description (const NMConfigData *config_data);
char *nm_config_data_get_value (const NMConfigData *config_data, const char *group, const char *key, GError **error);
char *nm_config_data_get_value (const NMConfigData *config_data, const char *group, const char *key);
const char *nm_config_data_get_connectivity_uri (const NMConfigData *config_data);
const guint nm_config_data_get_connectivity_interval (const NMConfigData *config_data);

View file

@ -124,8 +124,7 @@ is_managed_plugin (void)
char *result = NULL;
result = nm_config_data_get_value (nm_config_get_data_orig (nm_config_get ()),
IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED,
NULL);
IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED);
if (result) {
gboolean ret = is_true (result);
g_free (result);
@ -265,8 +264,7 @@ reload_connections (NMSystemConfigInterface *config)
nm_log_info (LOGD_SETTINGS, "Loading connections");
str_auto_refresh = nm_config_data_get_value (nm_config_get_data_orig (nm_config_get ()),
IFNET_KEY_FILE_GROUP, "auto_refresh",
NULL);
IFNET_KEY_FILE_GROUP, "auto_refresh");
if (str_auto_refresh && is_true (str_auto_refresh))
auto_refresh = TRUE;
g_free (str_auto_refresh);

View file

@ -328,7 +328,6 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
if_block *block = NULL;
NMInotifyHelper *inotify_helper;
char *value;
GError *error = NULL;
GList *keys, *iter;
GHashTableIter con_iter;
const char *block_name;
@ -457,17 +456,11 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
/* Check the config file to find out whether to manage interfaces */
value = nm_config_data_get_value (nm_config_get_data_orig (nm_config_get ()),
IFUPDOWN_KEY_FILE_GROUP, IFUPDOWN_KEY_FILE_KEY_MANAGED,
&error);
if (error) {
nm_log_info (LOGD_SETTINGS, "loading system config file (%s) caused error: %s",
nm_config_data_get_config_main_file (nm_config_get_data (nm_config_get ())),
error->message);
} else {
IFUPDOWN_KEY_FILE_GROUP, IFUPDOWN_KEY_FILE_KEY_MANAGED);
if (value) {
gboolean manage_well_known;
error = NULL;
manage_well_known = !g_strcmp0 (value, "true") || !g_strcmp0 (value, "1");
manage_well_known = !strcmp (value, "true") || !strcmp (value, "1");
priv->unmanage_well_known = !manage_well_known;
g_free (value);
}

View file

@ -91,7 +91,6 @@ static void
test_config_simple (void)
{
NMConfig *config;
GError *error = NULL;
const char **plugins;
char *value;
gs_unref_object NMDevice *dev50 = nm_test_device_new ("00:00:00:00:00:50");
@ -111,25 +110,21 @@ test_config_simple (void)
g_assert_cmpstr (plugins[1], ==, "bar");
g_assert_cmpstr (plugins[2], ==, "baz");
value = nm_config_data_get_value (nm_config_get_data_orig (config), "extra-section", "extra-key", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "extra-section", "extra-key");
g_assert_cmpstr (value, ==, "some value");
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "extra-section", "no-key", &error);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "extra-section", "no-key");
g_assert (!value);
g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND);
g_clear_error (&error);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "no-section", "no-key", &error);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "no-section", "no-key");
g_assert (!value);
g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND);
g_clear_error (&error);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "connection", "ipv6.ip6_privacy", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "connection", "ipv6.ip6_privacy");
g_assert_cmpstr (value, ==, "0");
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "connection.dev51", "ipv4.route-metric", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "connection.dev51", "ipv4.route-metric");
g_assert_cmpstr (value, ==, "51");
g_free (value);
@ -306,21 +301,21 @@ test_config_confdir (void)
g_assert_cmpstr (plugins[3], ==, "one");
g_assert_cmpstr (plugins[4], ==, "two");
value = nm_config_data_get_value (nm_config_get_data_orig (config), "main", "extra", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "main", "extra");
g_assert_cmpstr (value, ==, "hello");
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "main", "new", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "main", "new");
g_assert_cmpstr (value, ==, "something"); /* not ",something" */
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "order", "a", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "order", "a");
g_assert_cmpstr (value, ==, "90");
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "order", "b", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "order", "b");
g_assert_cmpstr (value, ==, "10");
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "order", "c", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "order", "c");
g_assert_cmpstr (value, ==, "0");
g_free (value);
@ -341,23 +336,23 @@ test_config_confdir (void)
ASSERT_GET_CONN_DEFAULT (config, "ord.key09", "C-2.1.09");
ASSERT_GET_CONN_DEFAULT (config, "ord.ovw01", "C-0.1.ovw01");
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val1", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val1");
g_assert_cmpstr (value, ==, "a,c");
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val2", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val2");
g_assert_cmpstr (value, ==, "VAL2");
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val3", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val3");
g_assert_cmpstr (value, ==, NULL);
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val4", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val4");
g_assert_cmpstr (value, ==, "vb,vb");
g_free (value);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val5", NULL);
value = nm_config_data_get_value (nm_config_get_data_orig (config), "append", "val5");
g_assert_cmpstr (value, ==, "VAL5");
g_free (value);