summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-02-21 15:34:55 +0100
committerThomas Haller <thaller@redhat.com>2017-02-21 15:43:03 +0100
commitc9f6cb9fe4234c5c6b2b187cddca9ad77ac84c64 (patch)
tree592d300dd62712fd569aba5d116fbcf3a506d2a3
parentccbfda5c0853a0b64661bee2b73b549a9849ecad (diff)
downloadNetworkManager-c9f6cb9fe4234c5c6b2b187cddca9ad77ac84c64.tar.gz
ifcfg: some refactoring of reader using vGetValueStr()/vGetValue_cp()
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c19
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c10
2 files changed, 11 insertions, 18 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index 17b8e8bb61..bbe990336f 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -145,12 +145,10 @@ make_connection_setting (const char *file,
if (!uuid)
uuid = nm_utils_uuid_generate_from_string (svFileGetName (ifcfg), -1, NM_UTILS_UUID_TYPE_LEGACY, NULL);
- stable_id = svGetValueStr_cp (ifcfg, "STABLE_ID");
-
g_object_set (s_con,
NM_SETTING_CONNECTION_TYPE, type,
NM_SETTING_CONNECTION_UUID, uuid,
- NM_SETTING_CONNECTION_STABLE_ID, stable_id,
+ NM_SETTING_CONNECTION_STABLE_ID, svGetValue (ifcfg, "STABLE_ID", &stable_id),
NULL);
g_free (uuid);
@@ -285,8 +283,8 @@ read_ip4_address (shvarFile *ifcfg,
nm_assert (tag);
nm_assert (!error || !*error);
- value = svGetValue (ifcfg, tag, &value_to_free);
- if (!value || !value[0]) {
+ value = svGetValueStr (ifcfg, tag, &value_to_free);
+ if (!value) {
NM_SET_OUT (out_has_key, FALSE);
NM_SET_OUT (out_addr, 0);
return TRUE;
@@ -335,23 +333,20 @@ is_any_ip4_address_defined (shvarFile *ifcfg, int *idx)
ret_idx = idx ? idx : &ignore;
for (i = -1; i <= 2; i++) {
- char tag[256];
gs_free char *value = NULL;
+ char tag[256];
- value = svGetValueStr_cp (ifcfg, numbered_tag (tag, "IPADDR", i));
- if (value) {
+ if (svGetValueStr (ifcfg, numbered_tag (tag, "IPADDR", i), &value)) {
*ret_idx = i;
return TRUE;
}
- value = svGetValueStr_cp (ifcfg, numbered_tag (tag, "PREFIX", i));
- if (value) {
+ if (svGetValueStr (ifcfg, numbered_tag (tag, "PREFIX", i), &value)) {
*ret_idx = i;
return TRUE;
}
- value = svGetValueStr_cp (ifcfg, numbered_tag (tag, "NETMASK", i));
- if (value) {
+ if (svGetValueStr (ifcfg, numbered_tag (tag, "NETMASK", i), &value)) {
*ret_idx = i;
return TRUE;
}
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index 1d76752b6b..6d4d5a3f9c 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -2459,7 +2459,6 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
char *tmp;
guint32 i, num, num4;
gint priority;
- GString *searches;
NMIPAddress *addr;
const char *dns;
gint64 route_metric;
@@ -2560,17 +2559,16 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
/* Write out DNS domains - 'DOMAIN' key is shared for both IPv4 and IPv6 domains */
num = nm_setting_ip_config_get_num_dns_searches (s_ip6);
if (num > 0) {
- char *ip4_domains;
- ip4_domains = svGetValueStr_cp (ifcfg, "DOMAIN");
- searches = g_string_new (ip4_domains);
+ gs_free char *ip4_domains = NULL;
+ nm_auto_free_gstring GString *searches = NULL;
+
+ searches = g_string_new (svGetValueStr (ifcfg, "DOMAIN", &ip4_domains));
for (i = 0; i < num; i++) {
if (searches->len > 0)
g_string_append_c (searches, ' ');
g_string_append (searches, nm_setting_ip_config_get_dns_search (s_ip6, i));
}
svSetValueStr (ifcfg, "DOMAIN", searches->str);
- g_string_free (searches, TRUE);
- g_free (ip4_domains);
}