From 301c747938c3daa78cb1b99a2feda65ade1a091e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 29 Jan 2016 15:48:23 +0100 Subject: [PATCH] settings: coding style and use gs_free in write_hostname() --- src/settings/nm-settings.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 688da2f8fa..80c7d23ea8 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -1532,9 +1532,10 @@ write_hostname (NMSettingsPrivate *priv, const char *hostname) char *hostname_eol; gboolean ret; gs_free_error GError *error = NULL; - char *file = priv->hostname.file, *link_path = NULL; + const char *file = priv->hostname.file; + gs_free char *link_path = NULL; gs_unref_variant GVariant *var = NULL; - struct stat file_stat = { .st_mode = 0 }; + struct stat file_stat; #if HAVE_SELINUX security_context_t se_ctx_prev = NULL, se_ctx = NULL; mode_t st_mode = 0; @@ -1558,8 +1559,9 @@ write_hostname (NMSettingsPrivate *priv, const char *hostname) * real file is located, otherwise g_file_set_contents will attempt to * replace the link with a plain file. */ - if (lstat (file, &file_stat) == 0 && S_ISLNK (file_stat.st_mode) && - (link_path = g_file_read_link (file, NULL))) + if ( lstat (file, &file_stat) == 0 + && S_ISLNK (file_stat.st_mode) + && (link_path = g_file_read_link (file, NULL))) file = link_path; #if HAVE_SELINUX @@ -1592,7 +1594,6 @@ write_hostname (NMSettingsPrivate *priv, const char *hostname) #endif g_free (hostname_eol); - g_free (link_path); if (!ret) { nm_log_warn (LOGD_SETTINGS, "Could not save hostname to %s: %s", file, error->message);