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.
This commit is contained in:
Thomas Haller 2020-01-09 11:48:18 +01:00
parent cd0863a339
commit 0f9664f417
3 changed files with 5 additions and 4 deletions

View file

@ -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);
}

View file

@ -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, } };

View file

@ -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,