summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-06-09 08:17:28 +0200
committerThomas Haller <thaller@redhat.com>2015-07-02 15:50:03 +0200
commita5f7abb842b037cbb21b1456c7681d0c93e91d36 (patch)
tree98a866a3c216a62b5121bc79df6b11795c631dcc /src
parent7fbfaf567df0562e6b9c39954087dc897c5e05b6 (diff)
downloadNetworkManager-a5f7abb842b037cbb21b1456c7681d0c93e91d36.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/nm-config-data.c6
-rw-r--r--src/nm-config-data.h2
-rw-r--r--src/settings/plugins/ifnet/plugin.c6
-rw-r--r--src/settings/plugins/ifupdown/plugin.c13
-rw-r--r--src/settings/plugins/keyfile/plugin.c8
-rw-r--r--src/tests/config/test-config.c35
6 files changed, 29 insertions, 41 deletions
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index d5e8314656..7266ffe967 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -108,11 +108,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 *
diff --git a/src/nm-config-data.h b/src/nm-config-data.h
index 56d11a01a9..5708190c24 100644
--- a/src/nm-config-data.h
+++ b/src/nm-config-data.h
@@ -84,7 +84,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);
diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c
index 95de868e6e..814fd238b8 100644
--- a/src/settings/plugins/ifnet/plugin.c
+++ b/src/settings/plugins/ifnet/plugin.c
@@ -85,8 +85,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);
@@ -219,8 +218,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);
diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c
index 2c30da0256..fc828bd312 100644
--- a/src/settings/plugins/ifupdown/plugin.c
+++ b/src/settings/plugins/ifupdown/plugin.c
@@ -303,7 +303,6 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
GHashTable *auto_ifaces;
if_block *block = NULL;
char *value;
- GError *error = NULL;
GList *keys, *iter;
GHashTableIter con_iter;
const char *block_name;
@@ -421,17 +420,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);
}
diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c
index ee7da79630..5ca0374b3d 100644
--- a/src/settings/plugins/keyfile/plugin.c
+++ b/src/settings/plugins/keyfile/plugin.c
@@ -323,8 +323,8 @@ config_changed_cb (NMConfig *config,
{
gs_free char *old_value = NULL, *new_value = NULL;
- old_value = nm_config_data_get_value (old_data, "keyfile", "unmanaged-devices", NULL);
- new_value = nm_config_data_get_value (config_data, "keyfile", "unmanaged-devices", NULL);
+ old_value = nm_config_data_get_value (old_data, "keyfile", "unmanaged-devices");
+ new_value = nm_config_data_get_value (config_data, "keyfile", "unmanaged-devices");
if (g_strcmp0 (old_value, new_value) != 0)
g_signal_emit_by_name (self, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
@@ -526,7 +526,7 @@ get_unmanaged_specs (NMSystemConfigInterface *config)
SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (config);
gs_free char *value = NULL;
- value = nm_config_data_get_value (nm_config_get_data (priv->config), "keyfile", "unmanaged-devices", NULL);
+ value = nm_config_data_get_value (nm_config_get_data (priv->config), "keyfile", "unmanaged-devices");
return nm_match_spec_split (value);
}
@@ -647,7 +647,7 @@ nm_settings_keyfile_plugin_new (void)
priv->config = g_object_ref (nm_config_get ());
value = nm_config_data_get_value (nm_config_get_data (priv->config),
- "keyfile", "hostname", NULL);
+ "keyfile", "hostname");
if (value) {
nm_log_warn (LOGD_SETTINGS, "keyfile: 'hostname' option is deprecated and has no effect");
g_free (value);
diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c
index 8c4043cf51..995511f519 100644
--- a/src/tests/config/test-config.c
+++ b/src/tests/config/test-config.c
@@ -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);