mirror of
https://git.proxmox.com/git/mirror_frr
synced 2026-01-28 05:35:46 +00:00
lib: ZEBRA_NUM_OF -> array_size
The latter is widely used, e.g. in the Linux kernel. Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
parent
0d019561bd
commit
7e3a1ec742
@ -854,7 +854,7 @@ void zprivs_init(struct zebra_privs_t *zprivs)
|
||||
zprivs->user, zprivs->vty_group);
|
||||
exit(1);
|
||||
}
|
||||
if (i >= ngroups && ngroups < (int)ZEBRA_NUM_OF(groups)) {
|
||||
if (i >= ngroups && ngroups < (int)array_size(groups)) {
|
||||
groups[i] = zprivs_state.vtygrp;
|
||||
}
|
||||
}
|
||||
|
||||
@ -472,7 +472,7 @@ unsigned int sockunion_hash(const union sockunion *su)
|
||||
return jhash_1word(su->sin.sin_addr.s_addr, 0);
|
||||
case AF_INET6:
|
||||
return jhash2(su->sin6.sin6_addr.s6_addr32,
|
||||
ZEBRA_NUM_OF(su->sin6.sin6_addr.s6_addr32), 0);
|
||||
array_size(su->sin6.sin6_addr.s6_addr32), 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -335,8 +335,6 @@ struct in_pktinfo {
|
||||
|
||||
#endif /* ndef BYTE_ORDER */
|
||||
|
||||
#define ZEBRA_NUM_OF(x) (sizeof (x) / sizeof (x[0]))
|
||||
|
||||
/* For old definition. */
|
||||
#ifndef IN6_ARE_ADDR_EQUAL
|
||||
#define IN6_ARE_ADDR_EQUAL IN6_IS_ADDR_EQUAL
|
||||
|
||||
@ -55,7 +55,7 @@ struct zebra_privs_t nhrpd_privs = {
|
||||
.vty_group = VTY_GROUP,
|
||||
#endif
|
||||
.caps_p = _caps_p,
|
||||
.cap_num_p = ZEBRA_NUM_OF(_caps_p),
|
||||
.cap_num_p = array_size(_caps_p),
|
||||
};
|
||||
|
||||
static void parse_arguments(int argc, char **argv)
|
||||
|
||||
@ -102,7 +102,7 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)
|
||||
{
|
||||
char buf[2][SU_ADDRSTRLEN];
|
||||
struct child_sa *sa = NULL, *lsa;
|
||||
uint32_t child_hash = child_id % ZEBRA_NUM_OF(childlist_head);
|
||||
uint32_t child_hash = child_id % array_size(childlist_head);
|
||||
int abort_migration = 0;
|
||||
|
||||
list_for_each_entry(lsa, &childlist_head[child_hash], childlist_entry)
|
||||
@ -202,7 +202,7 @@ void nhrp_vc_init(void)
|
||||
size_t i;
|
||||
|
||||
nhrp_vc_hash = hash_create(nhrp_vc_key, nhrp_vc_cmp, "NHRP VC hash");
|
||||
for (i = 0; i < ZEBRA_NUM_OF(childlist_head); i++)
|
||||
for (i = 0; i < array_size(childlist_head); i++)
|
||||
list_init(&childlist_head[i]);
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ void nhrp_vc_reset(void)
|
||||
struct child_sa *sa, *n;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < ZEBRA_NUM_OF(childlist_head); i++) {
|
||||
for (i = 0; i < array_size(childlist_head); i++) {
|
||||
list_for_each_entry_safe(sa, n, &childlist_head[i],
|
||||
childlist_entry)
|
||||
nhrp_vc_ipsec_updown(sa->id, 0);
|
||||
|
||||
@ -171,7 +171,7 @@ static void ares_address_cb(void *arg, int status, int timeouts,
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < ZEBRA_NUM_OF(addr) && he->h_addr_list[i] != NULL; i++) {
|
||||
for (i = 0; i < array_size(addr) && he->h_addr_list[i] != NULL; i++) {
|
||||
memset(&addr[i], 0, sizeof(addr[i]));
|
||||
addr[i].sa.sa_family = he->h_addrtype;
|
||||
switch (he->h_addrtype) {
|
||||
|
||||
@ -196,7 +196,7 @@ int zbufq_write(struct zbuf_queue *zbq, int fd)
|
||||
iov[iovcnt++] = (struct iovec){
|
||||
.iov_base = zb->head, .iov_len = zbuf_used(zb),
|
||||
};
|
||||
if (iovcnt >= ZEBRA_NUM_OF(iov))
|
||||
if (iovcnt >= array_size(iov))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +158,7 @@ static int netlink_route_info_add_nh(netlink_route_info_t *ri,
|
||||
memset(&nhi, 0, sizeof(nhi));
|
||||
src = NULL;
|
||||
|
||||
if (ri->num_nhs >= (int)ZEBRA_NUM_OF(ri->nhs))
|
||||
if (ri->num_nhs >= (int)array_size(ri->nhs))
|
||||
return 0;
|
||||
|
||||
nhi.recursive = nexthop->rparent ? 1 : 0;
|
||||
|
||||
@ -176,7 +176,7 @@ static Fpm__AddRoute *create_add_route_message(qpb_allocator_t *allocator,
|
||||
if (num_nhs >= multipath_num)
|
||||
break;
|
||||
|
||||
if (num_nhs >= ZEBRA_NUM_OF(nexthops))
|
||||
if (num_nhs >= array_size(nexthops))
|
||||
break;
|
||||
|
||||
if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE) {
|
||||
|
||||
@ -3482,7 +3482,7 @@ struct route_table *rib_tables_iter_next(rib_tables_iter_t *iter)
|
||||
while (1) {
|
||||
|
||||
while (iter->afi_safi_ix
|
||||
< (int)ZEBRA_NUM_OF(afi_safis)) {
|
||||
< (int)array_size(afi_safis)) {
|
||||
table = zebra_vrf_table(
|
||||
afi_safis[iter->afi_safi_ix].afi,
|
||||
afi_safis[iter->afi_safi_ix].safi,
|
||||
|
||||
@ -2135,7 +2135,7 @@ static unsigned int neigh_hash_keymake(void *p)
|
||||
return jhash_1word(ip->ipaddr_v4.s_addr, 0);
|
||||
|
||||
return jhash2(ip->ipaddr_v6.s6_addr32,
|
||||
ZEBRA_NUM_OF(ip->ipaddr_v6.s6_addr32), 0);
|
||||
array_size(ip->ipaddr_v6.s6_addr32), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user