ifcfg-rh: inline unnecessary function write_ip6_setting_dhcp_hostname()

If a function is only called once, it may not help to simplify the code
but make it more complicated. It would only simplify the code, if it
had a clear, distinct purpose. That isn't the case here. Also, the
IPv4 writer doesn't have such a function either. Drop and inline it.
This commit is contained in:
Thomas Haller 2020-02-14 15:41:28 +01:00
parent 4c101f36ec
commit d06092acbd

View file

@ -2614,28 +2614,6 @@ write_ip4_aliases (NMConnection *connection, const char *base_ifcfg_path)
}
}
static void
write_ip6_setting_dhcp_hostname (NMSettingIPConfig *s_ip6, shvarFile *ifcfg)
{
NMDhcpHostnameFlags flags;
const char *hostname;
hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6);
svSetValueStr (ifcfg, "DHCPV6_HOSTNAME", hostname);
/* Missing DHCPV6_SEND_HOSTNAME means TRUE, and we prefer not write it
* explicitly in that case, because it is NM-specific variable
*/
if (!nm_setting_ip_config_get_dhcp_send_hostname (s_ip6))
svSetValueStr (ifcfg, "DHCPV6_SEND_HOSTNAME", "no");
flags = nm_setting_ip_config_get_dhcp_hostname_flags (s_ip6);
svSetValueInt64_cond (ifcfg,
"DHCPV6_HOSTNAME_FLAGS",
flags != NM_DHCP_HOSTNAME_FLAG_NONE,
flags);
}
static gboolean
write_ip6_setting (NMConnection *connection,
shvarFile *ifcfg,
@ -2651,6 +2629,8 @@ write_ip6_setting (NMConnection *connection,
NMIPRouteTableSyncMode route_table;
GString *ip_str1, *ip_str2, *ip_ptr;
NMSettingIP6ConfigAddrGenMode addr_gen_mode;
NMDhcpHostnameFlags flags;
const char *hostname;
NM_SET_OUT (out_route6_content, NULL);
@ -2690,7 +2670,20 @@ write_ip6_setting (NMConnection *connection,
svSetValueStr (ifcfg, "DHCPV6_IAID",
nm_setting_ip_config_get_dhcp_iaid (s_ip6));
write_ip6_setting_dhcp_hostname (s_ip6, ifcfg);
hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6);
svSetValueStr (ifcfg, "DHCPV6_HOSTNAME", hostname);
/* Missing DHCPV6_SEND_HOSTNAME means TRUE, and we prefer not write it
* explicitly in that case, because it is NM-specific variable
*/
if (!nm_setting_ip_config_get_dhcp_send_hostname (s_ip6))
svSetValueStr (ifcfg, "DHCPV6_SEND_HOSTNAME", "no");
flags = nm_setting_ip_config_get_dhcp_hostname_flags (s_ip6);
svSetValueInt64_cond (ifcfg,
"DHCPV6_HOSTNAME_FLAGS",
flags != NM_DHCP_HOSTNAME_FLAG_NONE,
flags);
/* Write out IP addresses */
num = nm_setting_ip_config_get_num_addresses (s_ip6);