summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/privs.c2
-rw-r--r--lib/sockunion.c2
-rw-r--r--lib/zebra.h2
-rw-r--r--nhrpd/nhrp_main.c2
-rw-r--r--nhrpd/nhrp_vc.c6
-rw-r--r--nhrpd/resolver.c2
-rw-r--r--nhrpd/zbuf.c2
-rw-r--r--zebra/zebra_fpm_netlink.c2
-rw-r--r--zebra/zebra_fpm_protobuf.c2
-rw-r--r--zebra/zebra_rib.c2
-rw-r--r--zebra/zebra_vxlan.c2
11 files changed, 12 insertions, 14 deletions
diff --git a/lib/privs.c b/lib/privs.c
index 59f24afe4a..50f80e3c02 100644
--- a/lib/privs.c
+++ b/lib/privs.c
@@ -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;
}
}
diff --git a/lib/sockunion.c b/lib/sockunion.c
index af4f41f37c..bb5426d74a 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -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;
}
diff --git a/lib/zebra.h b/lib/zebra.h
index 7b83fed926..b1ea43c747 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -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
diff --git a/nhrpd/nhrp_main.c b/nhrpd/nhrp_main.c
index 9b8599eded..d7c485f0a0 100644
--- a/nhrpd/nhrp_main.c
+++ b/nhrpd/nhrp_main.c
@@ -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)
diff --git a/nhrpd/nhrp_vc.c b/nhrpd/nhrp_vc.c
index f92ea4ac90..fa3549f5ed 100644
--- a/nhrpd/nhrp_vc.c
+++ b/nhrpd/nhrp_vc.c
@@ -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);
diff --git a/nhrpd/resolver.c b/nhrpd/resolver.c
index 830f0e1c84..64b16e7ee3 100644
--- a/nhrpd/resolver.c
+++ b/nhrpd/resolver.c
@@ -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) {
diff --git a/nhrpd/zbuf.c b/nhrpd/zbuf.c
index c662295083..7f1475cc69 100644
--- a/nhrpd/zbuf.c
+++ b/nhrpd/zbuf.c
@@ -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;
}
diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c
index 28333526a7..bdc1dcdff3 100644
--- a/zebra/zebra_fpm_netlink.c
+++ b/zebra/zebra_fpm_netlink.c
@@ -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;
diff --git a/zebra/zebra_fpm_protobuf.c b/zebra/zebra_fpm_protobuf.c
index be0f6a23be..0f95c9ba8b 100644
--- a/zebra/zebra_fpm_protobuf.c
+++ b/zebra/zebra_fpm_protobuf.c
@@ -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) {
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index e47499b065..e675ca0a7a 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -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,
diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c
index 3a8426e772..285fe3200e 100644
--- a/zebra/zebra_vxlan.c
+++ b/zebra/zebra_vxlan.c
@@ -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);
}
/*