summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-05-25 15:41:39 +0200
committerThomas Haller <thaller@redhat.com>2018-05-26 20:11:04 +0200
commit5bd3f7bd67987de7e1194e5e3caa063d106c7e07 (patch)
tree8d509190876f730cb4a3825d027f3533632ec238
parent181cf5c709a35af51c6d49ad0455ec54d64f94a2 (diff)
downloadNetworkManager-5bd3f7bd67987de7e1194e5e3caa063d106c7e07.tar.gz
dhcp: cache errno in nm_dhcp_client_stop_existing() before using it
-rw-r--r--src/dhcp/nm-dhcp-client.c6
-rw-r--r--src/dhcp/nm-dhcp-dhclient.c10
2 files changed, 10 insertions, 6 deletions
diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c
index 60901692fb..ba517606ed 100644
--- a/src/dhcp/nm-dhcp-client.c
+++ b/src/dhcp/nm-dhcp-client.c
@@ -659,8 +659,10 @@ nm_dhcp_client_stop_existing (const char *pid_file, const char *binary_name)
out:
if (remove (pid_file) == -1) {
- nm_log_dbg (LOGD_DHCP, "dhcp: could not remove pid file \"%s\": %d (%s)",
- pid_file, errno, g_strerror (errno));
+ int errsv = errno;
+
+ nm_log_dbg (LOGD_DHCP, "dhcp: could not remove pid file \"%s\": %s (%d)",
+ pid_file, g_strerror (errsv), errsv);
}
}
diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c
index 0dfc448810..38ad205709 100644
--- a/src/dhcp/nm-dhcp-dhclient.c
+++ b/src/dhcp/nm-dhcp-dhclient.c
@@ -545,10 +545,12 @@ stop (NMDhcpClient *client, gboolean release, GBytes *duid)
if (remove (priv->conf_file) == -1)
_LOGD ("could not remove dhcp config file \"%s\": %d (%s)", priv->conf_file, errno, g_strerror (errno));
if (priv->pid_file) {
- if (remove (priv->pid_file) == -1)
- _LOGD ("could not remove dhcp pid file \"%s\": %d (%s)", priv->pid_file, errno, g_strerror (errno));
- g_free (priv->pid_file);
- priv->pid_file = NULL;
+ if (remove (priv->pid_file) == -1) {
+ int errsv = errno;
+
+ _LOGD ("could not remove dhcp pid file \"%s\": %s (%d)", priv->pid_file, g_strerror (errsv), errsv);
+ }
+ nm_clear_g_free (&priv->pid_file);
}
if (release) {