summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-01-09 11:48:18 +0100
committerThomas Haller <thaller@redhat.com>2020-01-28 11:17:41 +0100
commit0f9664f4177d9d5b888acef2b4492bc4f22ed920 (patch)
treefbc8ae0bedcb122585d108d74d3d5f659ee2cc42
parentcd0863a339d87e2c0cda8e9b521cd0dec5e3e5a7 (diff)
downloadNetworkManager-0f9664f4177d9d5b888acef2b4492bc4f22ed920.tar.gz
shared: use static array indices in function parameter declarations of _nm_utils_inet[46]_ntop()
This should give the compiler more possibilities to warn about wrong use of the API. In practice, my current compiler wouldn't flag any issues. However, some compilers (or compile options) might.
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.h4
-rw-r--r--src/nm-core-utils.c3
-rw-r--r--src/nm-core-utils.h2
3 files changed, 5 insertions, 4 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h
index abe263c6bd..2d4054f7c2 100644
--- a/shared/nm-glib-aux/nm-shared-utils.h
+++ b/shared/nm-glib-aux/nm-shared-utils.h
@@ -183,13 +183,13 @@ nm_utils_inet_ntop (int addr_family, gconstpointer addr, char *dst)
}
static inline const char *
-_nm_utils_inet4_ntop (in_addr_t addr, char *dst)
+_nm_utils_inet4_ntop (in_addr_t addr, char dst[static INET_ADDRSTRLEN])
{
return nm_utils_inet_ntop (AF_INET, &addr, dst);
}
static inline const char *
-_nm_utils_inet6_ntop (const struct in6_addr *addr, char *dst)
+_nm_utils_inet6_ntop (const struct in6_addr *addr, char dst[static INET6_ADDRSTRLEN])
{
return nm_utils_inet_ntop (AF_INET6, addr, dst);
}
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c
index 03dbbcf81f..cbbac2816b 100644
--- a/src/nm-core-utils.c
+++ b/src/nm-core-utils.c
@@ -2999,7 +2999,8 @@ nm_utils_ipv6_interface_identifier_get_from_token (NMUtilsIPv6IfaceId *iid,
* Returns: the input buffer filled with the id as string.
*/
const char *
-nm_utils_inet6_interface_identifier_to_token (NMUtilsIPv6IfaceId iid, char *buf)
+nm_utils_inet6_interface_identifier_to_token (NMUtilsIPv6IfaceId iid,
+ char buf[static INET6_ADDRSTRLEN])
{
struct in6_addr i6_token = { .s6_addr = { 0, } };
diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h
index 7d63d06afc..fbb7987573 100644
--- a/src/nm-core-utils.h
+++ b/src/nm-core-utils.h
@@ -316,7 +316,7 @@ gboolean nm_utils_ipv6_interface_identifier_get_from_token (NMUtilsIPv6IfaceId *
const char *token);
const char *nm_utils_inet6_interface_identifier_to_token (NMUtilsIPv6IfaceId iid,
- char *buf);
+ char buf[static INET6_ADDRSTRLEN]);
gboolean nm_utils_get_ipv6_interface_identifier (NMLinkType link_type,
const guint8 *hwaddr,