mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 07:00:13 +01:00
settings: coding style and use gs_free in write_hostname()
This commit is contained in:
parent
55a07b4ca4
commit
301c747938
1 changed files with 6 additions and 5 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue