summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-05-25 10:55:50 +0200
committerThomas Haller <thaller@redhat.com>2018-05-26 20:11:04 +0200
commit97dc1ec1e4026e9bd41db73e6ce318097e192612 (patch)
tree00b8c9f80c99757b1a9742e334fea3474b304a45
parent1c5e7902775b895a9c57abfeec5a63da98d628e9 (diff)
downloadNetworkManager-97dc1ec1e4026e9bd41db73e6ce318097e192612.tar.gz
dhcp: minor cleanup initializing name of leasefile for NMDhcpDhclint
-rw-r--r--src/dhcp/nm-dhcp-dhclient.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c
index 1c0b4bb3ac..0dfc448810 100644
--- a/src/dhcp/nm-dhcp-dhclient.c
+++ b/src/dhcp/nm-dhcp-dhclient.c
@@ -605,7 +605,7 @@ get_duid (NMDhcpClient *client)
g_free (leasefile);
}
- if (!duid && priv->def_leasefile) {
+ if (!duid) {
/* Otherwise read the default machine-wide DUID */
_LOGD ("looking for default DUID in '%s'", priv->def_leasefile);
duid = nm_dhcp_dhclient_read_duid (priv->def_leasefile, &error);
@@ -623,31 +623,25 @@ get_duid (NMDhcpClient *client)
/*****************************************************************************/
-static const char *def_leasefiles[] = {
- SYSCONFDIR "/dhclient6.leases",
- LOCALSTATEDIR "/lib/dhcp/dhclient6.leases",
- LOCALSTATEDIR "/lib/dhclient/dhclient6.leases",
- NULL
-};
-
static void
nm_dhcp_dhclient_init (NMDhcpDhclient *self)
{
+ static const char *const FILES[] = {
+ SYSCONFDIR "/dhclient6.leases", /* default */
+ LOCALSTATEDIR "/lib/dhcp/dhclient6.leases",
+ LOCALSTATEDIR "/lib/dhclient/dhclient6.leases",
+ };
NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self);
- const char **iter = &def_leasefiles[0];
+ int i;
- while (iter && *iter) {
- if (g_file_test (*iter, G_FILE_TEST_EXISTS)) {
- priv->def_leasefile = *iter;
+ priv->def_leasefile = FILES[0];
+ for (i = 0; i < G_N_ELEMENTS (FILES); i++) {
+ if (g_file_test (FILES[i], G_FILE_TEST_EXISTS)) {
+ priv->def_leasefile = FILES[i];
break;
}
- iter++;
}
- /* Fallback option */
- if (!priv->def_leasefile)
- priv->def_leasefile = SYSCONFDIR "/dhclient6.leases";
-
priv->dhcp_listener = g_object_ref (nm_dhcp_listener_get ());
g_signal_connect (priv->dhcp_listener,
NM_DHCP_LISTENER_EVENT,