summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-06-09 09:12:01 +0200
committerThomas Haller <thaller@redhat.com>2015-07-02 15:50:04 +0200
commit1b0ab2129c2789c476b2376da4c8e3d45c05b548 (patch)
treeefb4df0b6e4424b92f52b8fbf9fb49c7219d7c2f
parenta0e92799af0b21c698cd9c4147b7d8870018437f (diff)
downloadNetworkManager-1b0ab2129c2789c476b2376da4c8e3d45c05b548.tar.gz
config: use nm_config_data_get_value_boolean()
This removes duplicate parsing, but also makes all places use the same str-to-boolean convention.
-rw-r--r--src/settings/plugins/ifnet/plugin.c24
-rw-r--r--src/settings/plugins/ifupdown/plugin.c18
2 files changed, 12 insertions, 30 deletions
diff --git a/src/settings/plugins/ifnet/plugin.c b/src/settings/plugins/ifnet/plugin.c
index 3f7a7db9e9..552a480994 100644
--- a/src/settings/plugins/ifnet/plugin.c
+++ b/src/settings/plugins/ifnet/plugin.c
@@ -82,16 +82,9 @@ ignore_cb(NMSettingsConnectionInterface * connection,
static gboolean
is_managed_plugin (void)
{
- char *result = NULL;
-
- result = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
- IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED);
- if (result) {
- gboolean ret = is_true (result);
- g_free (result);
- return ret;
- }
- return IFNET_MANAGE_WELL_KNOWN_DEFAULT;
+ return nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG,
+ IFNET_KEY_FILE_GROUP, IFNET_KEY_FILE_KEY_MANAGED,
+ IFNET_MANAGE_WELL_KNOWN_DEFAULT);
}
static void
@@ -199,8 +192,7 @@ reload_connections (NMSystemConfigInterface *config)
SCPluginIfnet *self = SC_PLUGIN_IFNET (config);
SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (self);
GList *conn_names = NULL, *n_iter = NULL;
- gboolean auto_refresh = FALSE;
- char *str_auto_refresh;
+ gboolean auto_refresh;
GError *error = NULL;
/* save names for removing unused connections */
@@ -217,11 +209,9 @@ reload_connections (NMSystemConfigInterface *config)
nm_log_info (LOGD_SETTINGS, "Loading connections");
- str_auto_refresh = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
- IFNET_KEY_FILE_GROUP, "auto_refresh");
- if (str_auto_refresh && is_true (str_auto_refresh))
- auto_refresh = TRUE;
- g_free (str_auto_refresh);
+ auto_refresh = nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG,
+ IFNET_KEY_FILE_GROUP, "auto_refresh",
+ FALSE);
new_connections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c
index 081de24a57..0252a1ba47 100644
--- a/src/settings/plugins/ifupdown/plugin.c
+++ b/src/settings/plugins/ifupdown/plugin.c
@@ -302,7 +302,6 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self);
GHashTable *auto_ifaces;
if_block *block = NULL;
- char *value;
GList *keys, *iter;
GHashTableIter con_iter;
const char *block_name;
@@ -328,8 +327,6 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
} else
g_signal_connect (priv->client, "uevent", G_CALLBACK (handle_uevent), self);
- priv->unmanage_well_known = IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT;
-
/* Read in all the interfaces */
ifparser_init (ENI_INTERFACES_FILE, 0);
block = ifparser_getfirst ();
@@ -419,15 +416,10 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
g_hash_table_destroy (auto_ifaces);
/* Check the config file to find out whether to manage interfaces */
- value = nm_config_data_get_value (NM_CONFIG_GET_DATA_ORIG,
- IFUPDOWN_KEY_FILE_GROUP, IFUPDOWN_KEY_FILE_KEY_MANAGED);
- if (value) {
- gboolean manage_well_known;
-
- manage_well_known = !strcmp (value, "true") || !strcmp (value, "1");
- priv->unmanage_well_known = !manage_well_known;
- g_free (value);
- }
+ priv->unmanage_well_known = !nm_config_data_get_value_boolean (NM_CONFIG_GET_DATA_ORIG,
+ IFUPDOWN_KEY_FILE_GROUP,
+ IFUPDOWN_KEY_FILE_KEY_MANAGED,
+ !IFUPDOWN_UNMANAGE_WELL_KNOWN_DEFAULT);
nm_log_info (LOGD_SETTINGS, "management mode: %s", priv->unmanage_well_known ? "unmanaged" : "managed");
/* Add well-known interfaces */
@@ -517,7 +509,7 @@ sc_plugin_ifupdown_init (SCPluginIfupdown *plugin)
static void
GObject__get_property (GObject *object, guint prop_id,
- GValue *value, GParamSpec *pspec)
+ GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
case NM_SYSTEM_CONFIG_INTERFACE_PROP_NAME: