all: use internal _nm_utils_ip4_netmask_to_prefix()

We have two variants of the function: nm_utils_ip4_netmask_to_prefix()
and _nm_utils_ip4_netmask_to_prefix(). The former only exists because it
is public API in libnm. Internally, only use the latter.
This commit is contained in:
Thomas Haller 2022-06-23 07:43:20 +02:00
parent 05014b328f
commit 863b71a8fe
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
10 changed files with 11 additions and 11 deletions

View file

@ -805,7 +805,7 @@ handle_settings(GVariant *v_dict, gpointer user_data)
_LOGW("invalid 'Netmask': %s", s ?: "");
goto out;
}
address.plen = nm_utils_ip4_netmask_to_prefix(address_network);
address.plen = _nm_utils_ip4_netmask_to_prefix(address_network);
_LOGI("Address: %s", nm_platform_ip4_address_to_string(&address, sbuf, sizeof(sbuf)));
nm_l3_config_data_add_address_4(priv->l3cd_4, &address);

View file

@ -249,7 +249,7 @@ lease_parse_address(NDhcp4ClientLease *lease,
return FALSE;
}
a_plen = nm_utils_ip4_netmask_to_prefix(a_netmask);
a_plen = _nm_utils_ip4_netmask_to_prefix(a_netmask);
nm_dhcp_option_add_option_in_addr(options,
AF_INET,

View file

@ -423,7 +423,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
str = g_hash_table_lookup(options, "subnet_mask");
if (str && (inet_pton(AF_INET, str, &tmp_addr) > 0)) {
plen = nm_utils_ip4_netmask_to_prefix(tmp_addr);
plen = _nm_utils_ip4_netmask_to_prefix(tmp_addr);
_LOG2I(LOGD_DHCP4, iface, " plen %d (%s)", plen, str);
} else {
/* Get default netmask for the IP according to appropriate class. */

View file

@ -777,7 +777,7 @@ read_full_ip4_address(shvarFile *ifcfg,
if (!read_ip4_address(ifcfg, numbered_tag(tag, "NETMASK", which), &has_key, &a, error))
return FALSE;
if (has_key)
prefix = nm_utils_ip4_netmask_to_prefix(a);
prefix = _nm_utils_ip4_netmask_to_prefix(a);
else {
if (base_addr)
prefix = nm_ip_address_get_prefix(base_addr);
@ -1450,7 +1450,7 @@ read_one_ip4_route(shvarFile *ifcfg, guint32 which, NMIPRoute **out_route, GErro
error))
return FALSE;
if (has_key) {
prefix = nm_utils_ip4_netmask_to_prefix(netmask);
prefix = _nm_utils_ip4_netmask_to_prefix(netmask);
if (netmask != _nm_utils_ip4_prefix_to_netmask(prefix)) {
g_set_error(error,
NM_SETTINGS_ERROR,

View file

@ -451,7 +451,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, if_block *block, GErr
netmask_v);
return FALSE;
} else {
netmask_int = nm_utils_ip4_netmask_to_prefix(tmp_mask);
netmask_int = _nm_utils_ip4_netmask_to_prefix(tmp_mask);
}
}

View file

@ -3131,7 +3131,7 @@ _signal_handle(NMSupplicantInterface *self,
_set_p2p_assigned_addr(iface,
addr_data,
nm_utils_ip4_netmask_to_prefix(netmask));
_nm_utils_ip4_netmask_to_prefix(netmask));
} else {
_LOGW("P2P: GroupStarted signaled invalid IP Address information");
}

View file

@ -4925,7 +4925,7 @@ _netmask_to_prefix(guint32 netmask)
/* we re-implemented the netmask-to-prefix code differently. Check
* that they agree. */
g_assert_cmpint(prefix, ==, nm_utils_ip4_netmask_to_prefix(netmask));
g_assert_cmpint(prefix, ==, _nm_utils_ip4_netmask_to_prefix(netmask));
return prefix;
}

View file

@ -203,7 +203,7 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
g_bytes_get_data(response, NULL),
NULL,
&netmask_bin)) {
config_iface_data->cidr_prefix = nm_utils_ip4_netmask_to_prefix(netmask_bin);
config_iface_data->cidr_prefix = _nm_utils_ip4_netmask_to_prefix(netmask_bin);
};
break;

View file

@ -633,7 +633,7 @@ reader_parse_ip(Reader *reader, const char *sysfs_dir, char *argument)
NMIPAddr addr;
if (is_ipv4 && nm_utils_parse_inaddr_bin(AF_INET, netmask, NULL, &addr))
client_ip_prefix = nm_utils_ip4_netmask_to_prefix(addr.addr4);
client_ip_prefix = _nm_utils_ip4_netmask_to_prefix(addr.addr4);
else
client_ip_prefix = _nm_utils_ascii_str_to_int64(netmask, 10, 0, is_ipv4 ? 32 : 128, -1);

View file

@ -288,7 +288,7 @@ nmi_dt_reader_parse(const char *sysfs_dir)
guint32 netmask_v4;
nm_ip_address_get_address_binary(netmask, &netmask_v4);
prefix = nm_utils_ip4_netmask_to_prefix(netmask_v4);
prefix = _nm_utils_ip4_netmask_to_prefix(netmask_v4);
}
if (prefix == -1)