summaryrefslogtreecommitdiff
path: root/libnm-core
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-01-09 11:29:27 +0100
committerThomas Haller <thaller@redhat.com>2020-01-28 11:17:41 +0100
commitcd0863a339d87e2c0cda8e9b521cd0dec5e3e5a7 (patch)
tree963ccf42a0c8b25a85632d9d564bdfc5a4232c5b /libnm-core
parentc0bd6752b977603331e5f8ea056f0f15d436d622 (diff)
downloadNetworkManager-cd0863a339d87e2c0cda8e9b521cd0dec5e3e5a7.tar.gz
all: use _nm_utils_inet4_ntop() instead of nm_utils_inet4_ntop()
and _nm_utils_inet6_ntop() instead of nm_utils_inet6_ntop(). nm_utils_inet4_ntop()/nm_utils_inet6_ntop() are public API of libnm. For one, that means they are only available in code that links with libnm/libnm-core. But such basic helpers should be available everywhere. Also, they accept NULL as destination buffers. We keep that behavior for potential libnm users, but internally we never want to use the static buffers. This patch needs to take care that there are no callers of _nm_utils_inet[46]_ntop() that pass NULL buffers. Also, _nm_utils_inet[46]_ntop() are inline functions and the compiler can get rid of them. We should consistently use the same variant of the helper. The only downside is that the "good" name is already taken. The leading underscore is rather ugly and inconsistent. Also, with our internal variants we can use "static array indices in function parameter declarations" next. Thereby the compiler helps to ensure that the provided buffers are of the right size.
Diffstat (limited to 'libnm-core')
-rw-r--r--libnm-core/nm-connection.c2
-rw-r--r--libnm-core/nm-setting-ip6-config.c2
-rw-r--r--libnm-core/tests/test-general.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index 7c62bea2f3..36d2cd6dfe 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -999,7 +999,7 @@ _normalize_ip_config (NMConnection *self, GHashTable *parameters)
if ( inet_pton (AF_INET6, token, &i6_token) == 1
&& _nm_utils_inet6_is_token (&i6_token)) {
- nm_utils_inet6_ntop (&i6_token, normalized);
+ _nm_utils_inet6_ntop (&i6_token, normalized);
if (g_strcmp0 (token, normalized)) {
g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_TOKEN, normalized, NULL);
changed = TRUE;
diff --git a/libnm-core/nm-setting-ip6-config.c b/libnm-core/nm-setting-ip6-config.c
index bef4e061c9..eba7bc7f9d 100644
--- a/libnm-core/nm-setting-ip6-config.c
+++ b/libnm-core/nm-setting-ip6-config.c
@@ -235,7 +235,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return FALSE;
}
- if (g_strcmp0 (priv->token, nm_utils_inet6_ntop (&i6_token, s_token)))
+ if (g_strcmp0 (priv->token, _nm_utils_inet6_ntop (&i6_token, s_token)))
token_needs_normalization = TRUE;
} else {
g_set_error_literal (error,
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index 96f4af7ae4..9968f3613f 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -8341,8 +8341,8 @@ test_nm_ip_addr_zero (void)
g_assert (memcmp (&nm_ip_addr_zero, &a4, sizeof (a4)) == 0);
g_assert (memcmp (&nm_ip_addr_zero, &a6, sizeof (a6)) == 0);
- g_assert_cmpstr (nm_utils_inet4_ntop (nm_ip_addr_zero.addr4, buf), ==, "0.0.0.0");
- g_assert_cmpstr (nm_utils_inet6_ntop (&nm_ip_addr_zero.addr6, buf), ==, "::");
+ g_assert_cmpstr (_nm_utils_inet4_ntop (nm_ip_addr_zero.addr4, buf), ==, "0.0.0.0");
+ g_assert_cmpstr (_nm_utils_inet6_ntop (&nm_ip_addr_zero.addr6, buf), ==, "::");
g_assert_cmpstr (nm_utils_inet_ntop (AF_INET, &nm_ip_addr_zero, buf), ==, "0.0.0.0");
g_assert_cmpstr (nm_utils_inet_ntop (AF_INET6, &nm_ip_addr_zero, buf), ==, "::");