diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -2986,7 +2986,7 @@ MPASS(family_id != 0); ret = genl_register_cmds(CARP_NL_FAMILY_NAME, carp_cmds, - NL_ARRAY_LEN(carp_cmds)); + nitems(carp_cmds)); MPASS(ret); } diff --git a/sys/netlink/netlink_ctl.h b/sys/netlink/netlink_ctl.h --- a/sys/netlink/netlink_ctl.h +++ b/sys/netlink/netlink_ctl.h @@ -65,8 +65,6 @@ ((char *)NLA_NEXT(_attr) <= (char *)_end); \ _attr = (_len -= NLA_ALIGN(_attr->nla_len), NLA_NEXT(_attr))) -#define NL_ARRAY_LEN(_a) (sizeof(_a) / sizeof((_a)[0])) - #include #include diff --git a/sys/netlink/netlink_generic.c b/sys/netlink/netlink_generic.c --- a/sys/netlink/netlink_generic.c +++ b/sys/netlink/netlink_generic.c @@ -284,7 +284,7 @@ { NL_VERIFY_PARSERS(all_parsers); ctrl_family_id = genl_register_family(CTRL_FAMILY_NAME, 0, 2, CTRL_ATTR_MAX); - genl_register_cmds(CTRL_FAMILY_NAME, nlctrl_cmds, NL_ARRAY_LEN(nlctrl_cmds)); + genl_register_cmds(CTRL_FAMILY_NAME, nlctrl_cmds, nitems(nlctrl_cmds)); ctrl_group_id = genl_register_group(CTRL_FAMILY_NAME, "notify"); family_event_tag = EVENTHANDLER_REGISTER(genl_family_event, nlctrl_notify, NULL, EVENTHANDLER_PRI_ANY); diff --git a/sys/netlink/netlink_message_parser.h b/sys/netlink/netlink_message_parser.h --- a/sys/netlink/netlink_message_parser.h +++ b/sys/netlink/netlink_message_parser.h @@ -128,8 +128,8 @@ .nl_hdr_off = sizeof(_t), \ .fp = &((_fp)[0]), \ .np = &((_np)[0]), \ - .fp_size = NL_ARRAY_LEN(_fp), \ - .np_size = NL_ARRAY_LEN(_np), \ + .fp_size = nitems(_fp), \ + .np_size = nitems(_np), \ .sp = _sp, \ .post_parse = _pp, \ } @@ -146,14 +146,14 @@ .out_hdr_off = sizeof(_o), \ .fp = &((_fp)[0]), \ .np = &((_np)[0]), \ - .fp_size = NL_ARRAY_LEN(_fp), \ - .np_size = NL_ARRAY_LEN(_np), \ + .fp_size = nitems(_fp), \ + .np_size = nitems(_np), \ } #define NL_DECLARE_ATTR_PARSER_EXT(_name, _np, _pp) \ static const struct nlhdr_parser _name = { \ .np = &((_np)[0]), \ - .np_size = NL_ARRAY_LEN(_np), \ + .np_size = nitems(_np), \ .post_parse = (_pp) \ } @@ -308,7 +308,7 @@ #endif } void nl_verify_parsers(const struct nlhdr_parser **parser, int count); -#define NL_VERIFY_PARSERS(_p) nl_verify_parsers((_p), NL_ARRAY_LEN(_p)) +#define NL_VERIFY_PARSERS(_p) nl_verify_parsers((_p), nitems(_p)) static inline int nl_parse_nlmsg(struct nlmsghdr *hdr, const struct nlhdr_parser *parser, diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c --- a/sys/netlink/route/iface.c +++ b/sys/netlink/route/iface.c @@ -1522,7 +1522,7 @@ ifnet_link_event, rtnl_handle_iflink, NULL, EVENTHANDLER_PRI_ANY); NL_VERIFY_PARSERS(all_parsers); - rtnl_register_messages(cmd_handlers, NL_ARRAY_LEN(cmd_handlers)); + rtnl_register_messages(cmd_handlers, nitems(cmd_handlers)); } void diff --git a/sys/netlink/route/neigh.c b/sys/netlink/route/neigh.c --- a/sys/netlink/route/neigh.c +++ b/sys/netlink/route/neigh.c @@ -589,7 +589,7 @@ rtnl_neighs_init(void) { NL_VERIFY_PARSERS(all_parsers); - rtnl_register_messages(cmd_handlers, NL_ARRAY_LEN(cmd_handlers)); + rtnl_register_messages(cmd_handlers, nitems(cmd_handlers)); lle_event_p = EVENTHANDLER_REGISTER(lle_event, rtnl_lle_event, NULL, EVENTHANDLER_PRI_ANY); } diff --git a/sys/netlink/route/nexthop.c b/sys/netlink/route/nexthop.c --- a/sys/netlink/route/nexthop.c +++ b/sys/netlink/route/nexthop.c @@ -1119,5 +1119,5 @@ rtnl_nexthops_init(void) { NL_VERIFY_PARSERS(all_parsers); - rtnl_register_messages(cmd_handlers, NL_ARRAY_LEN(cmd_handlers)); + rtnl_register_messages(cmd_handlers, nitems(cmd_handlers)); } diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c --- a/sys/netlink/route/rt.c +++ b/sys/netlink/route/rt.c @@ -1119,5 +1119,5 @@ rtnl_routes_init(void) { NL_VERIFY_PARSERS(all_parsers); - rtnl_register_messages(cmd_handlers, NL_ARRAY_LEN(cmd_handlers)); + rtnl_register_messages(cmd_handlers, nitems(cmd_handlers)); } diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c --- a/sys/netpfil/pf/pf_nl.c +++ b/sys/netpfil/pf/pf_nl.c @@ -1985,7 +1985,7 @@ NL_VERIFY_PARSERS(all_parsers); family_id = genl_register_family(PFNL_FAMILY_NAME, 0, 2, PFNL_CMD_MAX); - genl_register_cmds(PFNL_FAMILY_NAME, pf_cmds, NL_ARRAY_LEN(pf_cmds)); + genl_register_cmds(PFNL_FAMILY_NAME, pf_cmds, nitems(pf_cmds)); } void diff --git a/sys/netpfil/pf/pflow.c b/sys/netpfil/pf/pflow.c --- a/sys/netpfil/pf/pflow.c +++ b/sys/netpfil/pf/pflow.c @@ -1786,7 +1786,8 @@ family_id = genl_register_family(PFLOWNL_FAMILY_NAME, 0, 2, PFLOWNL_CMD_MAX); MPASS(family_id != 0); - ret = genl_register_cmds(PFLOWNL_FAMILY_NAME, pflow_cmds, NL_ARRAY_LEN(pflow_cmds)); + ret = genl_register_cmds(PFLOWNL_FAMILY_NAME, pflow_cmds, + nitems(pflow_cmds)); return (ret ? 0 : ENODEV); } diff --git a/sys/tests/ktest.c b/sys/tests/ktest.c --- a/sys/tests/ktest.c +++ b/sys/tests/ktest.c @@ -370,7 +370,8 @@ family_id = genl_register_family(KTEST_FAMILY_NAME, 0, 1, KTEST_CMD_MAX); MPASS(family_id != 0); - ret = genl_register_cmds(KTEST_FAMILY_NAME, ktest_cmds, NL_ARRAY_LEN(ktest_cmds)); + ret = genl_register_cmds(KTEST_FAMILY_NAME, ktest_cmds, + nitems(ktest_cmds)); MPASS(ret); }