summaryrefslogtreecommitdiff
path: root/src/nm-config.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-10-23 10:29:51 +0200
committerThomas Haller <thaller@redhat.com>2016-10-23 10:52:57 +0200
commitb5aec6b7e768cffaa47d2d9311280ab5cf668d67 (patch)
treee58ed1ca0fa775bfb139d259632a948c16773816 /src/nm-config.c
parentf8c4a33f258dadd9bed4b6da7c8c917da1a9b6c3 (diff)
downloadNetworkManager-b5aec6b7e768cffaa47d2d9311280ab5cf668d67.tar.gz
config: cleanup ownership handling of @keyfile in read_entire_config()
Diffstat (limited to 'src/nm-config.c')
-rw-r--r--src/nm-config.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/nm-config.c b/src/nm-config.c
index fbd71a8db4..39593850f7 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -953,7 +953,7 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
char **out_config_description,
GError **error)
{
- GKeyFile *keyfile;
+ gs_unref_keyfile GKeyFile *keyfile = NULL;
gs_unref_ptrarray GPtrArray *system_confs = NULL;
gs_unref_ptrarray GPtrArray *confs = NULL;
gs_unref_ptrarray GPtrArray *run_confs = NULL;
@@ -983,10 +983,8 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
continue;
}
- if (!read_config (keyfile, FALSE, system_config_dir, filename, error)) {
- g_key_file_free (keyfile);
+ if (!read_config (keyfile, FALSE, system_config_dir, filename, error))
return NULL;
- }
i++;
}
@@ -999,26 +997,20 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
continue;
}
- if (!read_config (keyfile, FALSE, RUN_CONFIG_DIR, filename, error)) {
- g_key_file_free (keyfile);
+ if (!read_config (keyfile, FALSE, RUN_CONFIG_DIR, filename, error))
return NULL;
- }
i++;
}
/* First read the base config file */
- if (!read_base_config (keyfile, cli ? cli->config_main_file : NULL, &o_config_main_file, error)) {
- g_key_file_free (keyfile);
+ if (!read_base_config (keyfile, cli ? cli->config_main_file : NULL, &o_config_main_file, error))
return NULL;
- }
g_assert (o_config_main_file);
for (i = 0; i < confs->len; i++) {
- if (!read_config (keyfile, FALSE, config_dir, confs->pdata[i], error)) {
- g_key_file_free (keyfile);
+ if (!read_config (keyfile, FALSE, config_dir, confs->pdata[i], error))
return NULL;
- }
}
/* Merge settings from command line. They overwrite everything read from
@@ -1047,7 +1039,7 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
*out_config_description = g_string_free (str, FALSE);
}
NM_SET_OUT (out_config_main_file, g_steal_pointer (&o_config_main_file));
- return keyfile;
+ return g_steal_pointer (&keyfile);
}
static gboolean