]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: ZEBRA_NUM_OF -> array_size
authorDavid Lamparter <equinox@diac24.net>
Sat, 23 Mar 2019 13:53:58 +0000 (14:53 +0100)
committerDavid Lamparter <equinox@diac24.net>
Thu, 18 Apr 2019 10:44:29 +0000 (12:44 +0200)
The latter is widely used, e.g. in the Linux kernel.

Signed-off-by: David Lamparter <equinox@diac24.net>
lib/privs.c
lib/sockunion.c
lib/zebra.h
nhrpd/nhrp_main.c
nhrpd/nhrp_vc.c
nhrpd/resolver.c
nhrpd/zbuf.c
zebra/zebra_fpm_netlink.c
zebra/zebra_fpm_protobuf.c
zebra/zebra_rib.c
zebra/zebra_vxlan.c

index 59f24afe4a5aecc4a84f47b18a778401ed8d4dd1..50f80e3c020401d77195c544bb7cd01cecbba1cd 100644 (file)
@@ -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;
                }
        }
index af4f41f37ca380ec45a2f11267ef78cff7df7bf4..bb5426d74a8d70faa8698880563a56fcb143251a 100644 (file)
@@ -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;
 }
index 7b83fed926992a2a2711156ba997c46ce64bfcca..b1ea43c747cdde0817356a8eebc3a32b97a45424 100644 (file)
@@ -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
index 9b8599eded575dbce3184b67ab8d00874f0d668f..d7c485f0a0506895cb5e4722bb7ee7bb976ee0d9 100644 (file)
@@ -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)
index f92ea4ac900ed065e7f5ae8f11c639616f784b0f..fa3549f5edac0f8902dbc056f438fa3388acc4b2 100644 (file)
@@ -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);
index 830f0e1c84f8d62f168ff8b3d36073430334420f..64b16e7ee34d8d98dd1b4403568fb21b0de5a747 100644 (file)
@@ -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) {
index c662295083e79063f814c14bfeecdde45fd03880..7f1475cc69e1a2eb19f49e73f27534951b2c92fb 100644 (file)
@@ -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;
        }
 
index 28333526a7cf83c03ec8dddad822246aedceec23..bdc1dcdff3197716b1a39504bf0280030dd9c957 100644 (file)
@@ -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;
index be0f6a23be74224f4a83756306b5b30e784d4323..0f95c9ba8b7661e7c9065769994ae57915f758cd 100644 (file)
@@ -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) {
index e47499b0656deae821692861baa5f0b954f647fb..e675ca0a7a927254376f92d0315a9c50901ac830 100644 (file)
@@ -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,
index 3a8426e77257ac922d14610cb3d97e3ab5e8c0fd..285fe3200e78b0a8d4ca95a06370bafb0a109183 100644 (file)
@@ -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);
 }
 
 /*