all: replace NMP_IFNAMSIZ with NM_IFNAMSIZ

This commit is contained in:
Thomas Haller 2023-05-25 15:05:29 +02:00
parent 3fd656ed37
commit 3d71eddf63
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
7 changed files with 30 additions and 36 deletions

View file

@ -74,7 +74,7 @@ _nft_ifname_valid(const char *str)
return NULL;
}
}
if (i >= NMP_IFNAMSIZ)
if (i >= NM_IFNAMSIZ)
return NULL;
return str;
@ -154,10 +154,10 @@ _share_iptables_get_name(gboolean is_iptables_chain, const char *prefix, const c
nm_str_buf_append(&strbuf, prefix);
ip_iface_len = strlen(ip_iface);
G_STATIC_ASSERT_EXPR(NMP_IFNAMSIZ == 16);
if (ip_iface_len >= NMP_IFNAMSIZ) {
G_STATIC_ASSERT_EXPR(NM_IFNAMSIZ == 16);
if (ip_iface_len >= NM_IFNAMSIZ) {
nm_assert_not_reached();
ip_iface_len = NMP_IFNAMSIZ - 1;
ip_iface_len = NM_IFNAMSIZ - 1;
}
if (NM_STRCHAR_ALL(ip_iface,

View file

@ -49,8 +49,8 @@ nmtst_platform_ip4_address_full(const char *address,
{
NMPlatformIP4Address *addr = nmtst_platform_ip4_address(address, peer_address, plen);
G_STATIC_ASSERT(NMP_IFNAMSIZ == sizeof(addr->label));
g_assert(!label || strlen(label) < NMP_IFNAMSIZ);
G_STATIC_ASSERT(NM_IFNAMSIZ == sizeof(addr->label));
g_assert(!label || strlen(label) < NM_IFNAMSIZ);
addr->ifindex = ifindex;
addr->addr_source = source;

View file

@ -447,7 +447,7 @@ _create_iface_dbus_call_get_interface_cb(GObject *source, GAsyncResult *result,
nm_assert(handle->name_owner == priv->name_owner);
if (!res) {
char ifname[NMP_IFNAMSIZ];
char ifname[NM_IFNAMSIZ];
if (handle->create_iface_try_count < CREATE_IFACE_TRY_COUNT_MAX
&& nm_dbus_error_is(error, NM_WPAS_ERROR_UNKNOWN_IFACE)
@ -489,7 +489,7 @@ _create_iface_dbus_call_create_interface_cb(GObject *source,
gs_unref_variant GVariant *res = NULL;
gs_free_error GError *error = NULL;
const char *iface_path_str;
char ifname[NMP_IFNAMSIZ];
char ifname[NM_IFNAMSIZ];
res = g_dbus_connection_call_finish(dbus_connection, result, &error);
@ -619,7 +619,7 @@ static void
_create_iface_dbus_start(NMSupplicantManager *self, NMSupplMgrCreateIfaceHandle *handle)
{
NMSupplicantManagerPrivate *priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE(self);
char ifname[NMP_IFNAMSIZ];
char ifname[NM_IFNAMSIZ];
nm_assert(priv->name_owner);
nm_assert(!handle->cancellable);

View file

@ -151,8 +151,8 @@ nm_setting_infiniband_create_virtual_interface_name(const char *parent, int p_ke
char *s;
s = g_strdup_printf("%s.%04x", parent, (guint) p_key);
if (strlen(s) >= NMP_IFNAMSIZ)
s[NMP_IFNAMSIZ - 1] = '\0';
if (strlen(s) >= NM_IFNAMSIZ)
s[NM_IFNAMSIZ - 1] = '\0';
return s;
}

View file

@ -181,7 +181,7 @@ typedef union {
struct _NMPlatformLink {
__NMPlatformObjWithIfindex_COMMON;
char name[NMP_IFNAMSIZ];
char name[NM_IFNAMSIZ];
NMLinkType type;
/* rtnl_link_get_type(), IFLA_INFO_KIND. */
@ -545,8 +545,8 @@ typedef struct {
NMFibRuleUidRange uid_range; /* FRA_UID_RANGE */
NMFibRulePortRange sport_range; /* FRA_SPORT_RANGE */
NMFibRulePortRange dport_range; /* FRA_DPORT_RANGE */
char iifname[NMP_IFNAMSIZ]; /* FRA_IIFNAME */
char oifname[NMP_IFNAMSIZ]; /* FRA_OIFNAME */
char iifname[NM_IFNAMSIZ]; /* FRA_IIFNAME */
char oifname[NM_IFNAMSIZ]; /* FRA_OIFNAME */
guint8 addr_family; /* (struct fib_rule_hdr).family */
guint8 action; /* (struct fib_rule_hdr).action */
guint8 tos; /* (struct fib_rule_hdr).tos */
@ -1534,23 +1534,23 @@ const char *nm_link_type_to_string(NMLinkType link_type);
#define NMP_SYSCTL_PATHID_ABSOLUTE(path) ((const char *) NULL), -1, (path)
#define NMP_SYSCTL_PATHID_NETDIR_unsafe(dirfd, ifname, path) \
nm_sprintf_buf_unsafe_a(NM_STRLEN("net:/sys/class/net//\0") + NMP_IFNAMSIZ + ({ \
const gsize _l = strlen(path); \
\
nm_assert(_l < 200); \
_l; \
}), \
"net:/sys/class/net/%s/%s", \
(ifname), \
(path)), \
#define NMP_SYSCTL_PATHID_NETDIR_unsafe(dirfd, ifname, path) \
nm_sprintf_buf_unsafe_a(NM_STRLEN("net:/sys/class/net//\0") + NM_IFNAMSIZ + ({ \
const gsize _l = strlen(path); \
\
nm_assert(_l < 200); \
_l; \
}), \
"net:/sys/class/net/%s/%s", \
(ifname), \
(path)), \
(dirfd), (path)
#define NMP_SYSCTL_PATHID_NETDIR(dirfd, ifname, path) \
nm_sprintf_bufa(NM_STRLEN("net:/sys/class/net//" path "/\0") + NMP_IFNAMSIZ, \
"net:/sys/class/net/%s/%s", \
(ifname), \
path), \
#define NMP_SYSCTL_PATHID_NETDIR(dirfd, ifname, path) \
nm_sprintf_bufa(NM_STRLEN("net:/sys/class/net//" path "/\0") + NM_IFNAMSIZ, \
"net:/sys/class/net/%s/%s", \
(ifname), \
path), \
(dirfd), ("" path "")
int nm_platform_sysctl_open_netdir(NMPlatform *self, int ifindex, char *out_ifname);

View file

@ -11,12 +11,6 @@
/*****************************************************************************/
/* IFNAMSIZ is both defined in <linux/if.h> and <net/if.h>. In the past, these
* headers conflicted, so we cannot simply include either of them in a header-file.*/
#define NMP_IFNAMSIZ 16
/*****************************************************************************/
/* Define of the IN6_ADDR_GEN_MODE_* values to workaround old kernel headers
* that don't define it. */
#define NM_IN6_ADDR_GEN_MODE_UNKNOWN 255 /* no corresponding value. */

View file

@ -113,7 +113,7 @@ struct _NMPlatformIP4Address {
* See nm_platform_ip4_broadcast_address_from_addr(). */
in_addr_t broadcast_address;
char label[NMP_IFNAMSIZ];
char label[NM_IFNAMSIZ];
/* Whether the address is ready to be configured. By default, an address is, but this
* flag may indicate that the address is just for tracking purpose only, but the ACD