]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: Replace hash_cmp function return value to a bool
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 17 Oct 2018 19:27:12 +0000 (15:27 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 19 Oct 2018 17:14:45 +0000 (13:14 -0400)
The ->hash_cmp and linked list ->cmp functions were sometimes
being used interchangeably and this really is not a good
thing.  So let's modify the hash_cmp function pointer to return
a boolean and convert everything to use the new syntax.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
52 files changed:
bfdd/bfd.c
bgpd/bgp_advertise.c
bgpd/bgp_advertise.h
bgpd/bgp_aspath.c
bgpd/bgp_aspath.h
bgpd/bgp_attr.c
bgpd/bgp_attr.h
bgpd/bgp_community.c
bgpd/bgp_community.h
bgpd/bgp_ecommunity.c
bgpd/bgp_ecommunity.h
bgpd/bgp_evpn.c
bgpd/bgp_keepalives.c
bgpd/bgp_lcommunity.c
bgpd/bgp_lcommunity.h
bgpd/bgp_nexthop.c
bgpd/bgp_pbr.c
bgpd/bgp_pbr.h
bgpd/bgp_updgrp.c
bgpd/bgpd.c
isisd/fabricd.c
isisd/isis_spf_private.h
isisd/isis_tx_queue.c
lib/command.c
lib/distribute.c
lib/ferr.c
lib/hash.c
lib/hash.h
lib/if_rmap.c
lib/qobj.c
lib/routemap.c
lib/table.c
lib/thread.c
lib/vrf.c
nhrpd/nhrp_cache.c
nhrpd/nhrp_peer.c
nhrpd/nhrp_vc.c
nhrpd/reqid.c
ospfd/ospf_sr.c
pbrd/pbr_nht.c
pimd/pim_igmp.c
pimd/pim_msdp.c
pimd/pim_oil.c
pimd/pim_rpf.c
pimd/pim_rpf.h
pimd/pim_upstream.c
pimd/pim_upstream.h
staticd/static_zebra.c
zebra/zebra_mpls.c
zebra/zebra_pbr.c
zebra/zebra_pbr.h
zebra/zebra_vxlan.c

index 32fa02d99dde35b2931383b82c00d49637d69d3b..814366f32060ad19735d537f04facd616000464d 100644 (file)
@@ -861,15 +861,10 @@ static struct hash *bfd_vrf_hash;
 static struct hash *bfd_iface_hash;
 
 static unsigned int bfd_id_hash_do(void *p);
-static int bfd_id_hash_cmp(const void *n1, const void *n2);
 static unsigned int bfd_shop_hash_do(void *p);
-static int bfd_shop_hash_cmp(const void *n1, const void *n2);
 static unsigned int bfd_mhop_hash_do(void *p);
-static int bfd_mhop_hash_cmp(const void *n1, const void *n2);
 static unsigned int bfd_vrf_hash_do(void *p);
-static int bfd_vrf_hash_cmp(const void *n1, const void *n2);
 static unsigned int bfd_iface_hash_do(void *p);
-static int bfd_iface_hash_cmp(const void *n1, const void *n2);
 
 static void _shop_key(struct bfd_session *bs, const struct bfd_shop_key *shop);
 static void _shop_key2(struct bfd_session *bs, const struct bfd_shop_key *shop);
@@ -889,7 +884,7 @@ static unsigned int bfd_id_hash_do(void *p)
        return jhash_1word(bs->discrs.my_discr, 0);
 }
 
-static int bfd_id_hash_cmp(const void *n1, const void *n2)
+static bool bfd_id_hash_cmp(const void *n1, const void *n2)
 {
        const struct bfd_session *bs1 = n1, *bs2 = n2;
 
@@ -904,7 +899,7 @@ static unsigned int bfd_shop_hash_do(void *p)
        return jhash(&bs->shop, sizeof(bs->shop), 0);
 }
 
-static int bfd_shop_hash_cmp(const void *n1, const void *n2)
+static bool bfd_shop_hash_cmp(const void *n1, const void *n2)
 {
        const struct bfd_session *bs1 = n1, *bs2 = n2;
 
@@ -919,7 +914,7 @@ static unsigned int bfd_mhop_hash_do(void *p)
        return jhash(&bs->mhop, sizeof(bs->mhop), 0);
 }
 
-static int bfd_mhop_hash_cmp(const void *n1, const void *n2)
+static bool bfd_mhop_hash_cmp(const void *n1, const void *n2)
 {
        const struct bfd_session *bs1 = n1, *bs2 = n2;
 
@@ -934,7 +929,7 @@ static unsigned int bfd_vrf_hash_do(void *p)
        return jhash_1word(vrf->vrf_id, 0);
 }
 
-static int bfd_vrf_hash_cmp(const void *n1, const void *n2)
+static bool bfd_vrf_hash_cmp(const void *n1, const void *n2)
 {
        const struct bfd_vrf *v1 = n1, *v2 = n2;
 
@@ -949,7 +944,7 @@ static unsigned int bfd_iface_hash_do(void *p)
        return string_hash_make(iface->ifname);
 }
 
-static int bfd_iface_hash_cmp(const void *n1, const void *n2)
+static bool bfd_iface_hash_cmp(const void *n1, const void *n2)
 {
        const struct bfd_iface *i1 = n1, *i2 = n2;
 
index be47cbb6d8a203b0d0ecf8d8561bdc120760a19b..5b2cb579217251915b3470f2a419434308b4aca3 100644 (file)
@@ -71,7 +71,7 @@ unsigned int baa_hash_key(void *p)
        return attrhash_key_make(baa->attr);
 }
 
-int baa_hash_cmp(const void *p1, const void *p2)
+bool baa_hash_cmp(const void *p1, const void *p2)
 {
        const struct bgp_advertise_attr *baa1 = p1;
        const struct bgp_advertise_attr *baa2 = p2;
index 6ff476e7b8987157ff3a7074f7c8e94b5528e479..1912aec1bfa5b3941e39f31c7a2f6fc13e6472d1 100644 (file)
@@ -177,7 +177,7 @@ extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *);
 extern void bgp_sync_init(struct peer *);
 extern void bgp_sync_delete(struct peer *);
 extern unsigned int baa_hash_key(void *p);
-extern int baa_hash_cmp(const void *p1, const void *p2);
+extern bool baa_hash_cmp(const void *p1, const void *p2);
 extern void bgp_advertise_add(struct bgp_advertise_attr *baa,
                              struct bgp_advertise *adv);
 extern struct bgp_advertise *bgp_advertise_new(void);
index 0924223ddc9a2414e93970b6b2b318a62cf57090..4f756519cafc3fbff1117e72cb8eef171910c5bf 100644 (file)
@@ -1726,23 +1726,23 @@ struct aspath *aspath_reconcile_as4(struct aspath *aspath,
 /* Compare leftmost AS value for MED check.  If as1's leftmost AS and
    as2's leftmost AS is same return 1. (confederation as-path
    only).  */
-int aspath_cmp_left_confed(const struct aspath *aspath1,
-                          const struct aspath *aspath2)
+bool aspath_cmp_left_confed(const struct aspath *aspath1,
+                           const struct aspath *aspath2)
 {
        if (!(aspath1 && aspath2))
-               return 0;
+               return false;
 
        if (!(aspath1->segments && aspath2->segments))
-               return 0;
+               return false;
 
        if ((aspath1->segments->type != AS_CONFED_SEQUENCE)
            || (aspath2->segments->type != AS_CONFED_SEQUENCE))
-               return 0;
+               return false;
 
        if (aspath1->segments->as[0] == aspath2->segments->as[0])
-               return 1;
+               return true;
 
-       return 0;
+       return false;
 }
 
 /* Delete all AS_CONFED_SEQUENCE/SET segments from aspath.
@@ -2008,7 +2008,7 @@ unsigned int aspath_key_make(void *p)
 }
 
 /* If two aspath have same value then return 1 else return 0 */
-int aspath_cmp(const void *arg1, const void *arg2)
+bool aspath_cmp(const void *arg1, const void *arg2)
 {
        const struct assegment *seg1 = ((const struct aspath *)arg1)->segments;
        const struct assegment *seg2 = ((const struct aspath *)arg2)->segments;
@@ -2016,18 +2016,18 @@ int aspath_cmp(const void *arg1, const void *arg2)
        while (seg1 || seg2) {
                int i;
                if ((!seg1 && seg2) || (seg1 && !seg2))
-                       return 0;
+                       return false;
                if (seg1->type != seg2->type)
-                       return 0;
+                       return false;
                if (seg1->length != seg2->length)
-                       return 0;
+                       return false;
                for (i = 0; i < seg1->length; i++)
                        if (seg1->as[i] != seg2->as[i])
-                               return 0;
+                               return false;
                seg1 = seg1->next;
                seg2 = seg2->next;
        }
-       return 1;
+       return true;
 }
 
 /* AS path hash initialize. */
index 1acc2f67a67ddc93f197f4960d06dc92fd6aabb6..9c9c687a6b7ae9d801dff98f2f2556d3446b733e 100644 (file)
@@ -85,9 +85,10 @@ extern struct aspath *aspath_filter_exclude(struct aspath *, struct aspath *);
 extern struct aspath *aspath_add_seq_n(struct aspath *, as_t, unsigned);
 extern struct aspath *aspath_add_seq(struct aspath *, as_t);
 extern struct aspath *aspath_add_confed_seq(struct aspath *, as_t);
-extern int aspath_cmp(const void *, const void *);
+extern bool aspath_cmp(const void *as1, const void *as2);
 extern int aspath_cmp_left(const struct aspath *, const struct aspath *);
-extern int aspath_cmp_left_confed(const struct aspath *, const struct aspath *);
+extern bool aspath_cmp_left_confed(const struct aspath *as1,
+                                  const struct aspath *as2xs);
 extern struct aspath *aspath_delete_confed_seq(struct aspath *);
 extern struct aspath *aspath_empty(void);
 extern struct aspath *aspath_empty_get(void);
index fb7db9d57eda86fc1f0432c94eea82926a7875d9..e183073eca5ae1eebd4f62bdb5fc8f26a7436e4c 100644 (file)
@@ -146,7 +146,7 @@ static unsigned int cluster_hash_key_make(void *p)
        return jhash(cluster->list, cluster->length, 0);
 }
 
-static int cluster_hash_cmp(const void *p1, const void *p2)
+static bool cluster_hash_cmp(const void *p1, const void *p2)
 {
        const struct cluster_list *cluster1 = p1;
        const struct cluster_list *cluster2 = p2;
@@ -355,7 +355,7 @@ static unsigned int encap_hash_key_make(void *p)
        return jhash(encap->value, encap->length, 0);
 }
 
-static int encap_hash_cmp(const void *p1, const void *p2)
+static bool encap_hash_cmp(const void *p1, const void *p2)
 {
        return encap_same((const struct bgp_attr_encap_subtlv *)p1,
                          (const struct bgp_attr_encap_subtlv *)p2);
@@ -441,7 +441,7 @@ static unsigned int transit_hash_key_make(void *p)
        return jhash(transit->val, transit->length, 0);
 }
 
-static int transit_hash_cmp(const void *p1, const void *p2)
+static bool transit_hash_cmp(const void *p1, const void *p2)
 {
        const struct transit *transit1 = p1;
        const struct transit *transit2 = p2;
@@ -527,7 +527,7 @@ unsigned int attrhash_key_make(void *p)
        return key;
 }
 
-int attrhash_cmp(const void *p1, const void *p2)
+bool attrhash_cmp(const void *p1, const void *p2)
 {
        const struct attr *attr1 = p1;
        const struct attr *attr2 = p2;
@@ -565,10 +565,10 @@ int attrhash_cmp(const void *p1, const void *p2)
                    && overlay_index_same(attr1, attr2)
                    && attr1->nh_ifindex == attr2->nh_ifindex
                    && attr1->nh_lla_ifindex == attr2->nh_lla_ifindex)
-                       return 1;
+                       return true;
        }
 
-       return 0;
+       return false;
 }
 
 static void attrhash_init(void)
index 4c8f98947e31e5fe02197624ec9e15771147cb7e..47a4182fee5a8de8d6ac9af972b0fe0b55bc836b 100644 (file)
@@ -287,7 +287,7 @@ extern bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *,
                                       mpls_label_t *, uint32_t, int, uint32_t);
 extern void bgp_dump_routes_attr(struct stream *, struct attr *,
                                 struct prefix *);
-extern int attrhash_cmp(const void *, const void *);
+extern bool attrhash_cmp(const void *arg1, const void *arg2);
 extern unsigned int attrhash_key_make(void *);
 extern void attr_show_all(struct vty *);
 extern unsigned long int attr_count(void);
index e40674d635982635742c2cdb71869b531684efb4..9e5eb273a09acca19f86abd6cf86862b64dc8ba8 100644 (file)
@@ -614,17 +614,17 @@ int community_match(const struct community *com1, const struct community *com2)
 
 /* If two aspath have same value then return 1 else return 0. This
    function is used by hash package. */
-int community_cmp(const struct community *com1, const struct community *com2)
+bool community_cmp(const struct community *com1, const struct community *com2)
 {
        if (com1 == NULL && com2 == NULL)
-               return 1;
+               return true;
        if (com1 == NULL || com2 == NULL)
-               return 0;
+               return false;
 
        if (com1->size == com2->size)
                if (memcmp(com1->val, com2->val, com1->size * 4) == 0)
-                       return 1;
-       return 0;
+                       return true;
+       return false;
 }
 
 /* Add com2 to the end of com1. */
@@ -902,7 +902,7 @@ void community_init(void)
 {
        comhash =
                hash_create((unsigned int (*)(void *))community_hash_make,
-                           (int (*)(const void *, const void *))community_cmp,
+                           (bool (*)(const void *, const void *))community_cmp,
                            "BGP Community Hash");
 }
 
index 61af9f038ca88351f5f781f889c7cb9168be1476..afb9876f29f00164a2797667a6a7d69adb7460cc 100644 (file)
@@ -77,7 +77,8 @@ extern char *community_str(struct community *, bool make_json);
 extern unsigned int community_hash_make(struct community *);
 extern struct community *community_str2com(const char *);
 extern int community_match(const struct community *, const struct community *);
-extern int community_cmp(const struct community *, const struct community *);
+extern bool community_cmp(const struct community *c1,
+                         const struct community *c2);
 extern struct community *community_merge(struct community *,
                                         struct community *);
 extern struct community *community_delete(struct community *,
index 2e5b219ef90c7cec7bceb79f5d2c663603b8e9ef..8029164184fe46d566e2967c32a1be210d8c8f4b 100644 (file)
@@ -253,16 +253,16 @@ unsigned int ecommunity_hash_make(void *arg)
 }
 
 /* Compare two Extended Communities Attribute structure.  */
-int ecommunity_cmp(const void *arg1, const void *arg2)
+bool ecommunity_cmp(const void *arg1, const void *arg2)
 {
        const struct ecommunity *ecom1 = arg1;
        const struct ecommunity *ecom2 = arg2;
 
        if (ecom1 == NULL && ecom2 == NULL)
-               return 1;
+               return true;
 
        if (ecom1 == NULL || ecom2 == NULL)
-               return 0;
+               return false;
 
        return (ecom1->size == ecom2->size
                && memcmp(ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE)
index c71f371a9738e2c91171c6cc8c789b4f9acf93ad..d43403ed8daf641ff17d300652bc593a80b9fe7b 100644 (file)
@@ -154,7 +154,7 @@ extern struct ecommunity *ecommunity_merge(struct ecommunity *,
                                           struct ecommunity *);
 extern struct ecommunity *ecommunity_uniq_sort(struct ecommunity *);
 extern struct ecommunity *ecommunity_intern(struct ecommunity *);
-extern int ecommunity_cmp(const void *, const void *);
+extern bool ecommunity_cmp(const void *arg1, const void *arg2);
 extern void ecommunity_unintern(struct ecommunity **);
 extern unsigned int ecommunity_hash_make(void *);
 extern struct ecommunity *ecommunity_str2com(const char *, int, int);
index d6ed84ff561505f775f9a88e8b94e974449b0511..b67d93d4f5b3978daf761301977d065c5de2db20 100644 (file)
@@ -92,16 +92,16 @@ static unsigned int esi_hash_keymake(void *p)
 /*
  * Compare two ESIs.
  */
-static int esi_cmp(const void *p1, const void *p2)
+static bool esi_cmp(const void *p1, const void *p2)
 {
        const struct evpnes *pes1 = p1;
        const struct evpnes *pes2 = p2;
 
        if (pes1 == NULL && pes2 == NULL)
-               return 1;
+               return true;
 
        if (pes1 == NULL || pes2 == NULL)
-               return 0;
+               return false;
 
        return (memcmp(pes1->esi.val, pes2->esi.val, ESI_BYTES) == 0);
 }
@@ -118,15 +118,15 @@ static unsigned int vni_hash_key_make(void *p)
 /*
  * Comparison function for vni hash
  */
-static int vni_hash_cmp(const void *p1, const void *p2)
+static bool vni_hash_cmp(const void *p1, const void *p2)
 {
        const struct bgpevpn *vpn1 = p1;
        const struct bgpevpn *vpn2 = p2;
 
        if (!vpn1 && !vpn2)
-               return 1;
+               return true;
        if (!vpn1 || !vpn2)
-               return 0;
+               return false;
        return (vpn1->vni == vpn2->vni);
 }
 
@@ -152,16 +152,16 @@ static unsigned int vrf_import_rt_hash_key_make(void *p)
 /*
  * Comparison function for vrf import rt hash
  */
-static int vrf_import_rt_hash_cmp(const void *p1, const void *p2)
+static bool vrf_import_rt_hash_cmp(const void *p1, const void *p2)
 {
        const struct vrf_irt_node *irt1 = p1;
        const struct vrf_irt_node *irt2 = p2;
 
        if (irt1 == NULL && irt2 == NULL)
-               return 1;
+               return true;
 
        if (irt1 == NULL || irt2 == NULL)
-               return 0;
+               return false;
 
        return (memcmp(irt1->rt.val, irt2->rt.val, ECOMMUNITY_SIZE) == 0);
 }
@@ -269,16 +269,16 @@ static unsigned int import_rt_hash_key_make(void *p)
 /*
  * Comparison function for import rt hash
  */
-static int import_rt_hash_cmp(const void *p1, const void *p2)
+static bool import_rt_hash_cmp(const void *p1, const void *p2)
 {
        const struct irt_node *irt1 = p1;
        const struct irt_node *irt2 = p2;
 
        if (irt1 == NULL && irt2 == NULL)
-               return 1;
+               return true;
 
        if (irt1 == NULL || irt2 == NULL)
-               return 0;
+               return false;
 
        return (memcmp(irt1->rt.val, irt2->rt.val, ECOMMUNITY_SIZE) == 0);
 }
index 91fa8fa3736f89203fca68073a554886b87d3f53..50aad70ddc56fd70eb5ea32d4292e8b13cd29d33 100644 (file)
@@ -123,10 +123,11 @@ static void peer_process(struct hash_backet *hb, void *arg)
                *next_update = diff;
 }
 
-static int peer_hash_cmp(const void *f, const void *s)
+static bool peer_hash_cmp(const void *f, const void *s)
 {
        const struct pkat *p1 = f;
        const struct pkat *p2 = s;
+
        return p1->peer == p2->peer;
 }
 
index 3e160bc56ed95b55d65dbe113400c810dcc04c61..ec6255abf8227c16598f387d1b297c80e099efb6 100644 (file)
@@ -313,7 +313,7 @@ unsigned int lcommunity_hash_make(void *arg)
 }
 
 /* Compare two Large Communities Attribute structure.  */
-int lcommunity_cmp(const void *arg1, const void *arg2)
+bool lcommunity_cmp(const void *arg1, const void *arg2)
 {
        const struct lcommunity *lcom1 = arg1;
        const struct lcommunity *lcom2 = arg2;
index c88a016396720c8267eeba59e3593f09728d05f0..23c777d9fd38da5720f6b025ff18def08a1d3164 100644 (file)
@@ -60,7 +60,7 @@ extern struct lcommunity *lcommunity_merge(struct lcommunity *,
                                           struct lcommunity *);
 extern struct lcommunity *lcommunity_uniq_sort(struct lcommunity *);
 extern struct lcommunity *lcommunity_intern(struct lcommunity *);
-extern int lcommunity_cmp(const void *, const void *);
+extern bool lcommunity_cmp(const void *arg1, const void *arg2);
 extern void lcommunity_unintern(struct lcommunity **);
 extern unsigned int lcommunity_hash_make(void *);
 extern struct hash *lcommunity_hash(void);
index 453afea24c39a18c1264f86a481a5b0b3e772352..5ed6fd6ebedea4880ff0de945ed51f846b884328 100644 (file)
@@ -123,7 +123,7 @@ static unsigned int bgp_tip_hash_key_make(void *p)
        return jhash_1word(addr->addr.s_addr, 0);
 }
 
-static int bgp_tip_hash_cmp(const void *p1, const void *p2)
+static bool bgp_tip_hash_cmp(const void *p1, const void *p2)
 {
        const struct tip_addr *addr1 = p1;
        const struct tip_addr *addr2 = p2;
@@ -246,7 +246,7 @@ static unsigned int bgp_address_hash_key_make(void *p)
        return jhash_1word(addr->addr.s_addr, 0);
 }
 
-static int bgp_address_hash_cmp(const void *p1, const void *p2)
+static bool bgp_address_hash_cmp(const void *p1, const void *p2)
 {
        const struct bgp_addr *addr1 = p1;
        const struct bgp_addr *addr2 = p2;
index 263a3ebf4da2b788b465264564539a00d702e336..edd8317c3161058c5bba53db19f1d19fa87c8fa0 100644 (file)
@@ -847,7 +847,7 @@ uint32_t bgp_pbr_match_hash_key(void *arg)
        return jhash_1word(pbm->type, key);
 }
 
-int bgp_pbr_match_hash_equal(const void *arg1, const void *arg2)
+bool bgp_pbr_match_hash_equal(const void *arg1, const void *arg2)
 {
        const struct bgp_pbr_match *r1, *r2;
 
@@ -855,35 +855,35 @@ int bgp_pbr_match_hash_equal(const void *arg1, const void *arg2)
        r2 = (const struct bgp_pbr_match *)arg2;
 
        if (r1->vrf_id != r2->vrf_id)
-               return 0;
+               return false;
 
        if (r1->type != r2->type)
-               return 0;
+               return false;
 
        if (r1->flags != r2->flags)
-               return 0;
+               return false;
 
        if (r1->action != r2->action)
-               return 0;
+               return false;
 
        if (r1->pkt_len_min != r2->pkt_len_min)
-               return 0;
+               return false;
 
        if (r1->pkt_len_max != r2->pkt_len_max)
-               return 0;
+               return false;
 
        if (r1->tcp_flags != r2->tcp_flags)
-               return 0;
+               return false;
 
        if (r1->tcp_mask_flags != r2->tcp_mask_flags)
-               return 0;
+               return false;
 
        if (r1->dscp_value != r2->dscp_value)
-               return 0;
+               return false;
 
        if (r1->fragment != r2->fragment)
-               return 0;
-       return 1;
+               return false;
+       return true;
 }
 
 uint32_t bgp_pbr_match_entry_hash_key(void *arg)
@@ -903,45 +903,41 @@ uint32_t bgp_pbr_match_entry_hash_key(void *arg)
        return key;
 }
 
-int bgp_pbr_match_entry_hash_equal(const void *arg1, const void *arg2)
+bool bgp_pbr_match_entry_hash_equal(const void *arg1, const void *arg2)
 {
        const struct bgp_pbr_match_entry *r1, *r2;
 
        r1 = (const struct bgp_pbr_match_entry *)arg1;
        r2 = (const struct bgp_pbr_match_entry *)arg2;
 
-       /* on updates, comparing
-        * backpointer is not necessary
-        */
-
-       /* unique value is self calculated
-        */
-
-       /* rate is ignored for now
+       /*
+        * on updates, comparing backpointer is not necessary
+        * unique value is self calculated
+        * rate is ignored for now
         */
 
        if (!prefix_same(&r1->src, &r2->src))
-               return 0;
+               return false;
 
        if (!prefix_same(&r1->dst, &r2->dst))
-               return 0;
+               return false;
 
        if (r1->src_port_min != r2->src_port_min)
-               return 0;
+               return false;
 
        if (r1->dst_port_min != r2->dst_port_min)
-               return 0;
+               return false;
 
        if (r1->src_port_max != r2->src_port_max)
-               return 0;
+               return false;
 
        if (r1->dst_port_max != r2->dst_port_max)
-               return 0;
+               return false;
 
        if (r1->proto != r2->proto)
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
 uint32_t bgp_pbr_action_hash_key(void *arg)
@@ -955,7 +951,7 @@ uint32_t bgp_pbr_action_hash_key(void *arg)
        return key;
 }
 
-int bgp_pbr_action_hash_equal(const void *arg1, const void *arg2)
+bool bgp_pbr_action_hash_equal(const void *arg1, const void *arg2)
 {
        const struct bgp_pbr_action *r1, *r2;
 
@@ -967,11 +963,12 @@ int bgp_pbr_action_hash_equal(const void *arg1, const void *arg2)
         * rate is ignored
         */
        if (r1->vrf_id != r2->vrf_id)
-               return 0;
+               return false;
 
        if (memcmp(&r1->nh, &r2->nh, sizeof(struct nexthop)))
-               return 0;
-       return 1;
+               return false;
+
+       return true;
 }
 
 struct bgp_pbr_action *bgp_pbr_action_rule_lookup(vrf_id_t vrf_id,
index d15cb39c32e22acf29ba37de7487fb26364ea46c..84095f9ab9456441acd95cd39915d622e5bd5f6a 100644 (file)
@@ -267,13 +267,13 @@ extern void bgp_pbr_cleanup(struct bgp *bgp);
 extern void bgp_pbr_init(struct bgp *bgp);
 
 extern uint32_t bgp_pbr_action_hash_key(void *arg);
-extern int bgp_pbr_action_hash_equal(const void *arg1,
+extern bool bgp_pbr_action_hash_equal(const void *arg1,
                                     const void *arg2);
 extern uint32_t bgp_pbr_match_entry_hash_key(void *arg);
-extern int bgp_pbr_match_entry_hash_equal(const void *arg1,
+extern bool bgp_pbr_match_entry_hash_equal(const void *arg1,
                                          const void *arg2);
 extern uint32_t bgp_pbr_match_hash_key(void *arg);
-extern int bgp_pbr_match_hash_equal(const void *arg1,
+extern bool bgp_pbr_match_hash_equal(const void *arg1,
                                    const void *arg2);
 
 void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api);
index 6ebfc4af02d49087a07b957e96205b6f479e3cba..393586dbecd0ebaca0ad2d740ee94ca246117ae8 100644 (file)
@@ -393,7 +393,7 @@ static unsigned int updgrp_hash_key_make(void *p)
        return key;
 }
 
-static int updgrp_hash_cmp(const void *p1, const void *p2)
+static bool updgrp_hash_cmp(const void *p1, const void *p2)
 {
        const struct update_group *grp1;
        const struct update_group *grp2;
@@ -407,7 +407,7 @@ static int updgrp_hash_cmp(const void *p1, const void *p2)
        safi_t safi;
 
        if (!p1 || !p2)
-               return 0;
+               return false;
 
        grp1 = p1;
        grp2 = p2;
@@ -422,68 +422,68 @@ static int updgrp_hash_cmp(const void *p1, const void *p2)
 
        /* put EBGP and IBGP peers in different update groups */
        if (pe1->sort != pe2->sort)
-               return 0;
+               return false;
 
        /* check peer flags */
        if ((pe1->flags & PEER_UPDGRP_FLAGS)
            != (pe2->flags & PEER_UPDGRP_FLAGS))
-               return 0;
+               return false;
 
        /* If there is 'local-as' configured, it should match. */
        if (pe1->change_local_as != pe2->change_local_as)
-               return 0;
+               return false;
 
        /* flags like route reflector client */
        if ((flags1 & PEER_UPDGRP_AF_FLAGS) != (flags2 & PEER_UPDGRP_AF_FLAGS))
-               return 0;
+               return false;
 
        if ((pe1->cap & PEER_UPDGRP_CAP_FLAGS)
            != (pe2->cap & PEER_UPDGRP_CAP_FLAGS))
-               return 0;
+               return false;
 
        if ((pe1->af_cap[afi][safi] & PEER_UPDGRP_AF_CAP_FLAGS)
            != (pe2->af_cap[afi][safi] & PEER_UPDGRP_AF_CAP_FLAGS))
-               return 0;
+               return false;
 
        if (pe1->v_routeadv != pe2->v_routeadv)
-               return 0;
+               return false;
 
        if (pe1->group != pe2->group)
-               return 0;
+               return false;
 
        /* route-map names should be the same */
        if ((fl1->map[RMAP_OUT].name && !fl2->map[RMAP_OUT].name)
            || (!fl1->map[RMAP_OUT].name && fl2->map[RMAP_OUT].name)
            || (fl1->map[RMAP_OUT].name && fl2->map[RMAP_OUT].name
                && strcmp(fl1->map[RMAP_OUT].name, fl2->map[RMAP_OUT].name)))
-               return 0;
+               return false;
 
        if ((fl1->dlist[FILTER_OUT].name && !fl2->dlist[FILTER_OUT].name)
            || (!fl1->dlist[FILTER_OUT].name && fl2->dlist[FILTER_OUT].name)
            || (fl1->dlist[FILTER_OUT].name && fl2->dlist[FILTER_OUT].name
                && strcmp(fl1->dlist[FILTER_OUT].name,
                          fl2->dlist[FILTER_OUT].name)))
-               return 0;
+               return false;
 
        if ((fl1->plist[FILTER_OUT].name && !fl2->plist[FILTER_OUT].name)
            || (!fl1->plist[FILTER_OUT].name && fl2->plist[FILTER_OUT].name)
            || (fl1->plist[FILTER_OUT].name && fl2->plist[FILTER_OUT].name
                && strcmp(fl1->plist[FILTER_OUT].name,
                          fl2->plist[FILTER_OUT].name)))
-               return 0;
+               return false;
 
        if ((fl1->aslist[FILTER_OUT].name && !fl2->aslist[FILTER_OUT].name)
            || (!fl1->aslist[FILTER_OUT].name && fl2->aslist[FILTER_OUT].name)
            || (fl1->aslist[FILTER_OUT].name && fl2->aslist[FILTER_OUT].name
                && strcmp(fl1->aslist[FILTER_OUT].name,
                          fl2->aslist[FILTER_OUT].name)))
-               return 0;
+               return false;
 
        if ((fl1->usmap.name && !fl2->usmap.name)
            || (!fl1->usmap.name && fl2->usmap.name)
            || (fl1->usmap.name && fl2->usmap.name
                && strcmp(fl1->usmap.name, fl2->usmap.name)))
-               return 0;
+               return false;
 
        if ((pe1->default_rmap[afi][safi].name
             && !pe2->default_rmap[afi][safi].name)
@@ -493,19 +493,19 @@ static int updgrp_hash_cmp(const void *p1, const void *p2)
                && pe2->default_rmap[afi][safi].name
                && strcmp(pe1->default_rmap[afi][safi].name,
                          pe2->default_rmap[afi][safi].name)))
-               return 0;
+               return false;
 
        if ((afi == AFI_IP6) && (pe1->shared_network != pe2->shared_network))
-               return 0;
+               return false;
 
        if ((CHECK_FLAG(pe1->flags, PEER_FLAG_LONESOUL)
             || CHECK_FLAG(pe1->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
             || CHECK_FLAG(pe1->af_cap[afi][safi],
                           PEER_CAP_ORF_PREFIX_SM_OLD_RCV))
            && !sockunion_same(&pe1->su, &pe2->su))
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
 static void peer_lonesoul_or_not(struct peer *peer, int set)
index 9272eae95fbfcce4fd6e74c86435fea96bc295a5..1e423724ae6a03179a71ba912c5a6fe58cbf2e63 100644 (file)
@@ -769,7 +769,7 @@ static unsigned int peer_hash_key_make(void *p)
        return sockunion_hash(&peer->su);
 }
 
-static int peer_hash_same(const void *p1, const void *p2)
+static bool peer_hash_same(const void *p1, const void *p2)
 {
        const struct peer *peer1 = p1;
        const struct peer *peer2 = p2;
index 7951efe5a114016c4d6353fea176fd01d600a277..76c8087f2d8331b14bfffee89a2552cd88adadaa 100644 (file)
@@ -105,7 +105,7 @@ static unsigned neighbor_entry_hash_key(void *np)
        return jhash(n->vertex->N.id, ISIS_SYS_ID_LEN, 0x55aa5a5a);
 }
 
-static int neighbor_entry_hash_cmp(const void *a, const void *b)
+static bool neighbor_entry_hash_cmp(const void *a, const void *b)
 {
        const struct neighbor_entry *na = a, *nb = b;
 
index 131fa37991a92baa9594b260cf4290f31c39f3eb..3a05df3f1493fd8733c1589adc7f7e21fa1cf570 100644 (file)
@@ -95,16 +95,16 @@ static unsigned isis_vertex_queue_hash_key(void *vp)
 }
 
 __attribute__((__unused__))
-static int isis_vertex_queue_hash_cmp(const void *a, const void *b)
+static bool isis_vertex_queue_hash_cmp(const void *a, const void *b)
 {
        const struct isis_vertex *va = a, *vb = b;
 
        if (va->type != vb->type)
-               return 0;
+               return false;
 
        if (VTYPE_IP(va->type)) {
                if (prefix_cmp(&va->N.ip.dest, &vb->N.ip.dest))
-                       return 0;
+                       return false;
 
                return prefix_cmp((const struct prefix *)&va->N.ip.src,
                                  (const struct prefix *)&vb->N.ip.src) == 0;
index 32427628ad474ef731214446f4b81240d0d43bea..fe67a3f4d19794b6c5d5871301d6f1b0efa87ce4 100644 (file)
@@ -58,18 +58,18 @@ static unsigned tx_queue_hash_key(void *p)
        return jhash_1word(e->lsp->level, id_key);
 }
 
-static int tx_queue_hash_cmp(const void *a, const void *b)
+static bool tx_queue_hash_cmp(const void *a, const void *b)
 {
        const struct isis_tx_queue_entry *ea = a, *eb = b;
 
        if (ea->lsp->level != eb->lsp->level)
-               return 0;
+               return false;
 
        if (memcmp(ea->lsp->hdr.lsp_id, eb->lsp->hdr.lsp_id,
                   ISIS_SYS_ID_LEN + 2))
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
 struct isis_tx_queue *isis_tx_queue_new(void *arg,
index 6fe4ae2d8f2cbbd9d0d154c287cb754f0498312b..839c37b10272f98067402ff1d5b8d63e32c27c7f 100644 (file)
@@ -337,7 +337,7 @@ static unsigned int cmd_hash_key(void *p)
        return jhash(p, size, 0);
 }
 
-static int cmd_hash_cmp(const void *a, const void *b)
+static bool cmd_hash_cmp(const void *a, const void *b)
 {
        return a == b;
 }
index 25fcd92580e10a6c603a25d54fe379e717c7ff6a..0f1d666aeb9ae3d1c98ee911671c705acec25cb5 100644 (file)
@@ -140,15 +140,15 @@ static unsigned int distribute_hash_make(void *arg)
 
 /* If two distribute-list have same value then return 1 else return
    0. This function is used by hash package. */
-static int distribute_cmp(const struct distribute *dist1,
+static bool distribute_cmp(const struct distribute *dist1,
                          const struct distribute *dist2)
 {
        if (dist1->ifname && dist2->ifname)
                if (strcmp(dist1->ifname, dist2->ifname) == 0)
-                       return 1;
+                       return true;
        if (!dist1->ifname && !dist2->ifname)
-               return 1;
-       return 0;
+               return true;
+       return false;
 }
 
 /* Set access-list name to the distribute list. */
@@ -521,7 +521,7 @@ void distribute_list_init(int node)
 {
        disthash = hash_create(
                distribute_hash_make,
-               (int (*)(const void *, const void *))distribute_cmp, NULL);
+               (bool (*)(const void *, const void *))distribute_cmp, NULL);
 
        /* vtysh command-extraction doesn't grok install_element(node, ) */
        if (node == RIP_NODE) {
index bf89cc7f461e83bb9118891fb45d880831d6edfd..e18597afb07c0a92537c26909516b1b4faa47983 100644 (file)
@@ -64,7 +64,7 @@ static void err_key_fini(void)
 pthread_mutex_t refs_mtx = PTHREAD_MUTEX_INITIALIZER;
 struct hash *refs;
 
-static int ferr_hash_cmp(const void *a, const void *b)
+static bool ferr_hash_cmp(const void *a, const void *b)
 {
        const struct log_ref *f_a = a;
        const struct log_ref *f_b = b;
index 114522a75a95c340b1ce34c9e88657aa3ae5e7d6..641c75136872800825d1795233e643e74406873a 100644 (file)
@@ -38,7 +38,7 @@ static struct list *_hashes;
 
 struct hash *hash_create_size(unsigned int size,
                              unsigned int (*hash_key)(void *),
-                             int (*hash_cmp)(const void *, const void *),
+                             bool (*hash_cmp)(const void *, const void *),
                              const char *name)
 {
        struct hash *hash;
@@ -67,7 +67,7 @@ struct hash *hash_create_size(unsigned int size,
 }
 
 struct hash *hash_create(unsigned int (*hash_key)(void *),
-                        int (*hash_cmp)(const void *, const void *),
+                        bool (*hash_cmp)(const void *, const void *),
                         const char *name)
 {
        return hash_create_size(HASH_INITIAL_SIZE, hash_key, hash_cmp, name);
index 2b4ea48f3812d6297da3fc3269c1d930ed4940a5..45ae6ce60a104ec82ed178e5be08152a59f17686 100644 (file)
@@ -73,7 +73,7 @@ struct hash {
        unsigned int (*hash_key)(void *);
 
        /* Data compare function. */
-       int (*hash_cmp)(const void *, const void *);
+       bool (*hash_cmp)(const void *, const void *);
 
        /* Backet alloc. */
        unsigned long count;
@@ -115,7 +115,7 @@ struct hash {
  *    a new hash table
  */
 extern struct hash *hash_create(unsigned int (*hash_key)(void *),
-                               int (*hash_cmp)(const void *, const void *),
+                               bool (*hash_cmp)(const void *, const void *),
                                const char *name);
 
 /*
@@ -150,7 +150,8 @@ extern struct hash *hash_create(unsigned int (*hash_key)(void *),
  */
 extern struct hash *
 hash_create_size(unsigned int size, unsigned int (*hash_key)(void *),
-                int (*hash_cmp)(const void *, const void *), const char *name);
+                bool (*hash_cmp)(const void *, const void *),
+                const char *name);
 
 /*
  * Retrieve or insert data from / into a hash table.
index 2c686ecb852e20effb0eac5a5e96b9bfcc32b843..108ab7ec6b5dacc737970eae4fb60dbbf766938e 100644 (file)
@@ -117,7 +117,7 @@ static unsigned int if_rmap_hash_make(void *data)
        return string_hash_make(if_rmap->ifname);
 }
 
-static int if_rmap_hash_cmp(const void *arg1, const void *arg2)
+static bool if_rmap_hash_cmp(const void *arg1, const void *arg2)
 {
        const struct if_rmap *if_rmap1 = arg1;
        const struct if_rmap *if_rmap2 = arg2;
index c3f1a27c8213cfc1bbbe400e782b275d5f34c9bd..811645f3c33e337387be81f2789a68d2b551b819 100644 (file)
@@ -36,7 +36,7 @@ static unsigned int qobj_key(void *data)
        return (unsigned int)node->nid;
 }
 
-static int qobj_cmp(const void *a, const void *b)
+static bool qobj_cmp(const void *a, const void *b)
 {
        const struct qobj_node *na = a, *nb = b;
        return na->nid == nb->nid;
index 3a20ed5cdaea91e83096de38c137b339a38123ff..1814bfc1b3a80e31cfbcd2d66c90eea637732139 100644 (file)
@@ -631,7 +631,7 @@ static unsigned int route_map_hash_key_make(void *p)
        return string_hash_make(map->name);
 }
 
-static int route_map_hash_cmp(const void *p1, const void *p2)
+static bool route_map_hash_cmp(const void *p1, const void *p2)
 {
        const struct route_map *map1 = p1;
        const struct route_map *map2 = p2;
@@ -639,14 +639,14 @@ static int route_map_hash_cmp(const void *p1, const void *p2)
        if (map1->deleted == map2->deleted) {
                if (map1->name && map2->name) {
                        if (!strcmp(map1->name, map2->name)) {
-                               return 1;
+                               return true;
                        }
                } else if (!map1->name && !map2->name) {
-                       return 1;
+                       return true;
                }
        }
 
-       return 0;
+       return false;
 }
 
 enum route_map_upd8_type {
@@ -676,7 +676,6 @@ struct route_map_dep {
 struct hash *route_map_dep_hash[ROUTE_MAP_DEP_MAX];
 
 static unsigned int route_map_dep_hash_make_key(void *p);
-static int route_map_dep_hash_cmp(const void *p1, const void *p2);
 static void route_map_clear_all_references(char *rmap_name);
 static void route_map_rule_delete(struct route_map_rule_list *,
                                  struct route_map_rule *);
@@ -1624,12 +1623,12 @@ void route_map_event_hook(void (*func)(route_map_event_t, const char *))
 }
 
 /* Routines for route map dependency lists and dependency processing */
-static int route_map_rmap_hash_cmp(const void *p1, const void *p2)
+static bool route_map_rmap_hash_cmp(const void *p1, const void *p2)
 {
        return (strcmp((const char *)p1, (const char *)p2) == 0);
 }
 
-static int route_map_dep_hash_cmp(const void *p1, const void *p2)
+static bool route_map_dep_hash_cmp(const void *p1, const void *p2)
 {
 
        return (strcmp(((const struct route_map_dep *)p1)->dep_name,
index 3adb7938912c5096be0fd4ae7eeb3cfe29bcaf53..0026b7692be758f4fa8c922aee9aaf1b4c67cea2 100644 (file)
@@ -33,7 +33,7 @@ DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node")
 
 static void route_table_free(struct route_table *);
 
-static int route_table_hash_cmp(const void *a, const void *b)
+static bool route_table_hash_cmp(const void *a, const void *b)
 {
        const struct prefix *pa = a, *pb = b;
        return prefix_cmp(pa, pb) == 0;
index 267dcd1cfce4c72c257ed07effca44ac18d077e3..d104c4f5988cb46721f49441f7af21ce64a85333 100644 (file)
@@ -68,7 +68,7 @@ static unsigned int cpu_record_hash_key(struct cpu_thread_history *a)
        return jhash(&a->func, size, 0);
 }
 
-static int cpu_record_hash_cmp(const struct cpu_thread_history *a,
+static bool cpu_record_hash_cmp(const struct cpu_thread_history *a,
                               const struct cpu_thread_history *b)
 {
        return a->func == b->func;
@@ -434,7 +434,7 @@ struct thread_master *thread_master_create(const char *name)
 
        rv->cpu_record = hash_create_size(
                8, (unsigned int (*)(void *))cpu_record_hash_key,
-               (int (*)(const void *, const void *))cpu_record_hash_cmp,
+               (bool (*)(const void *, const void *))cpu_record_hash_cmp,
                "Thread Hash");
 
 
index eca9913e1faddc7a3e3b6705dc029c89bbeac693..498aef45803b7bef31a39220b4043112617179a6 100644 (file)
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -366,7 +366,7 @@ static unsigned int vrf_hash_bitmap_key(void *data)
        return bit->vrf_id;
 }
 
-static int vrf_hash_bitmap_cmp(const void *a, const void *b)
+static bool vrf_hash_bitmap_cmp(const void *a, const void *b)
 {
        const struct vrf_bit_set *bit1 = a;
        const struct vrf_bit_set *bit2 = b;
index f3a33eb28f2cda76876ec533f2bf21e788461199..1316a4aad3a6d759649bfc8b7c87f90dfa960570 100644 (file)
@@ -36,10 +36,12 @@ static unsigned int nhrp_cache_protocol_key(void *peer_data)
        return sockunion_hash(&p->remote_addr);
 }
 
-static int nhrp_cache_protocol_cmp(const void *cache_data, const void *key_data)
+static bool nhrp_cache_protocol_cmp(const void *cache_data,
+                                   const void *key_data)
 {
        const struct nhrp_cache *a = cache_data;
        const struct nhrp_cache *b = key_data;
+
        return sockunion_same(&a->remote_addr, &b->remote_addr);
 }
 
index 203d4aa98cdd0126f8d4138fd4f064611040d586..db2f72ac2211e4d4e19ba320c9e51f6448f151c9 100644 (file)
@@ -157,10 +157,11 @@ static unsigned int nhrp_peer_key(void *peer_data)
        return sockunion_hash(&p->vc->remote.nbma);
 }
 
-static int nhrp_peer_cmp(const void *cache_data, const void *key_data)
+static bool nhrp_peer_cmp(const void *cache_data, const void *key_data)
 {
        const struct nhrp_peer *a = cache_data;
        const struct nhrp_peer *b = key_data;
+
        return a->ifp == b->ifp && a->vc == b->vc;
 }
 
index 41a87d4adbc181c0170ae450da8d633158b53354..79a655396b543c1442357cd00c814e58e85150b4 100644 (file)
@@ -35,10 +35,11 @@ static unsigned int nhrp_vc_key(void *peer_data)
                            sockunion_hash(&vc->remote.nbma), 0);
 }
 
-static int nhrp_vc_cmp(const void *cache_data, const void *key_data)
+static bool nhrp_vc_cmp(const void *cache_data, const void *key_data)
 {
        const struct nhrp_vc *a = cache_data;
        const struct nhrp_vc *b = key_data;
+
        return sockunion_same(&a->local.nbma, &b->local.nbma)
               && sockunion_same(&a->remote.nbma, &b->remote.nbma);
 }
index e8ad518e5890926e3bf9e538e2760e99c4525ad9..08a007bdf933c19adb3537e16f1aef517a997419 100644 (file)
@@ -8,9 +8,10 @@ static unsigned int nhrp_reqid_key(void *data)
        return r->request_id;
 }
 
-static int nhrp_reqid_cmp(const void *data, const void *key)
+static bool nhrp_reqid_cmp(const void *data, const void *key)
 {
        const struct nhrp_reqid *a = data, *b = key;
+
        return a->request_id == b->request_id;
 }
 
index d793735003b25a72d1a336d30e41989754eff783..e0295d29c1200ab5861d52017079fc22e9a806ff 100644 (file)
@@ -94,7 +94,7 @@ static unsigned int sr_hash(void *p)
 }
 
 /* Compare 2 Router ID hash entries based on SR Node */
-static int sr_cmp(const void *p1, const void *p2)
+static bool sr_cmp(const void *p1, const void *p2)
 {
        const struct sr_node *srn = p1;
        const struct in_addr *rid = p2;
index 7376e3e95bbd9b448740f27b4c093b9d518156b9..6103bd7db5e2cf71a6e85f90cc018c480b040aac 100644 (file)
@@ -69,7 +69,7 @@ static void *pbr_nhrc_hash_alloc(void *p)
        return nhrc;
 }
 
-static int pbr_nhrc_hash_equal(const void *arg1, const void *arg2)
+static bool pbr_nhrc_hash_equal(const void *arg1, const void *arg2)
 {
        const struct nexthop *nh1, *nh2;
 
@@ -139,7 +139,7 @@ static uint32_t pbr_nh_hash_key(void *arg)
        return key;
 }
 
-static int pbr_nh_hash_equal(const void *arg1, const void *arg2)
+static bool pbr_nh_hash_equal(const void *arg1, const void *arg2)
 {
        const struct pbr_nexthop_cache *pbrnc1 =
                (const struct pbr_nexthop_cache *)arg1;
@@ -147,25 +147,25 @@ static int pbr_nh_hash_equal(const void *arg1, const void *arg2)
                (const struct pbr_nexthop_cache *)arg2;
 
        if (pbrnc1->nexthop->vrf_id != pbrnc2->nexthop->vrf_id)
-               return 0;
+               return false;
 
        if (pbrnc1->nexthop->ifindex != pbrnc2->nexthop->ifindex)
-               return 0;
+               return false;
 
        if (pbrnc1->nexthop->type != pbrnc2->nexthop->type)
-               return 0;
+               return false;
 
        switch (pbrnc1->nexthop->type) {
        case NEXTHOP_TYPE_IFINDEX:
-               return 1;
+               return true;
        case NEXTHOP_TYPE_IPV4_IFINDEX:
        case NEXTHOP_TYPE_IPV4:
                return pbrnc1->nexthop->gate.ipv4.s_addr
                       == pbrnc2->nexthop->gate.ipv4.s_addr;
        case NEXTHOP_TYPE_IPV6_IFINDEX:
        case NEXTHOP_TYPE_IPV6:
-               return !memcmp(&pbrnc1->nexthop->gate.ipv6,
-                              &pbrnc2->nexthop->gate.ipv6, 16);
+               return !!memcmp(&pbrnc1->nexthop->gate.ipv6,
+                               &pbrnc2->nexthop->gate.ipv6, 16);
        case NEXTHOP_TYPE_BLACKHOLE:
                return pbrnc1->nexthop->bh_type == pbrnc2->nexthop->bh_type;
        }
@@ -173,7 +173,7 @@ static int pbr_nh_hash_equal(const void *arg1, const void *arg2)
        /*
         * We should not get here
         */
-       return 0;
+       return false;
 }
 
 static void pbr_nhgc_delete(struct pbr_nexthop_group_cache *p)
@@ -724,7 +724,7 @@ static uint32_t pbr_nhg_hash_key(void *arg)
        return jhash(&nhgc->name, strlen(nhgc->name), 0x52c34a96);
 }
 
-static int pbr_nhg_hash_equal(const void *arg1, const void *arg2)
+static bool pbr_nhg_hash_equal(const void *arg1, const void *arg2)
 {
        const struct pbr_nexthop_group_cache *nhgc1 =
                (const struct pbr_nexthop_group_cache *)arg1;
index 8a2efd41adbc86678b545744441eaee175f680e2..7a19d25a7b36f11eeed4dcd29fd691603b5ca218 100644 (file)
@@ -836,15 +836,15 @@ static unsigned int igmp_group_hash_key(void *arg)
        return jhash_1word(group->group_addr.s_addr, 0);
 }
 
-static int igmp_group_hash_equal(const void *arg1, const void *arg2)
+static bool igmp_group_hash_equal(const void *arg1, const void *arg2)
 {
        const struct igmp_group *g1 = (const struct igmp_group *)arg1;
        const struct igmp_group *g2 = (const struct igmp_group *)arg2;
 
        if (g1->group_addr.s_addr == g2->group_addr.s_addr)
-               return 1;
+               return true;
 
-       return 0;
+       return false;
 }
 
 static struct igmp_sock *igmp_sock_new(int fd, struct in_addr ifaddr,
index 9ef343a0c5d77cce189b725957bee29bace47d49..807ad2bd129279a9646311c86719cdc6c4d6745b 100644 (file)
@@ -687,7 +687,7 @@ static unsigned int pim_msdp_sa_hash_key_make(void *p)
        return (jhash_2words(sa->sg.src.s_addr, sa->sg.grp.s_addr, 0));
 }
 
-static int pim_msdp_sa_hash_eq(const void *p1, const void *p2)
+static bool pim_msdp_sa_hash_eq(const void *p1, const void *p2)
 {
        const struct pim_msdp_sa *sa1 = p1;
        const struct pim_msdp_sa *sa2 = p2;
@@ -1221,7 +1221,7 @@ static unsigned int pim_msdp_peer_hash_key_make(void *p)
        return (jhash_1word(mp->peer.s_addr, 0));
 }
 
-static int pim_msdp_peer_hash_eq(const void *p1, const void *p2)
+static bool pim_msdp_peer_hash_eq(const void *p1, const void *p2)
 {
        const struct pim_msdp_peer *mp1 = p1;
        const struct pim_msdp_peer *mp2 = p2;
index 68f7dae128029f03b43e1c693fdd9ce5979d6baa..1290bfe56b153d4ec3e658bbf56cd20c05f0ee70 100644 (file)
@@ -79,16 +79,16 @@ static int pim_channel_oil_compare(struct channel_oil *c1,
        return 0;
 }
 
-static int pim_oil_equal(const void *arg1, const void *arg2)
+static bool pim_oil_equal(const void *arg1, const void *arg2)
 {
        const struct channel_oil *c1 = (const struct channel_oil *)arg1;
        const struct channel_oil *c2 = (const struct channel_oil *)arg2;
 
        if ((c1->oil.mfcc_mcastgrp.s_addr == c2->oil.mfcc_mcastgrp.s_addr)
            && (c1->oil.mfcc_origin.s_addr == c2->oil.mfcc_origin.s_addr))
-               return 1;
+               return true;
 
-       return 0;
+       return false;
 }
 
 static unsigned int pim_oil_hash_key(void *arg)
index b02102c8fd88c80f671ec589e9e562e3bd967070..814d2e076bb0f581d5d20770432aed962166b024 100644 (file)
@@ -407,7 +407,7 @@ unsigned int pim_rpf_hash_key(void *arg)
        return jhash_1word(r->rpf.rpf_addr.u.prefix4.s_addr, 0);
 }
 
-int pim_rpf_equal(const void *arg1, const void *arg2)
+bool pim_rpf_equal(const void *arg1, const void *arg2)
 {
        const struct pim_nexthop_cache *r1 =
                (const struct pim_nexthop_cache *)arg1;
index 78bbfc7ed9992aaa3c9fccd0b1e31f44888a1260..b9fe162f21c66714fca28cea618ff40d195c4ba4 100644 (file)
@@ -57,7 +57,7 @@ enum pim_rpf_result { PIM_RPF_OK = 0, PIM_RPF_CHANGED, PIM_RPF_FAILURE };
 struct pim_upstream;
 
 unsigned int pim_rpf_hash_key(void *arg);
-int pim_rpf_equal(const void *arg1, const void *arg2);
+bool pim_rpf_equal(const void *arg1, const void *arg2);
 
 int pim_nexthop_lookup(struct pim_instance *pim, struct pim_nexthop *nexthop,
                       struct in_addr addr, int neighbor_needed);
index cd6326f0978e99edf200cec9d335e5ba9fa9c417..e5f5b34f2f857da8fc484d7c0f8599b07b3416d8 100644 (file)
@@ -1554,16 +1554,16 @@ void pim_upstream_terminate(struct pim_instance *pim)
        pim->upstream_sg_wheel = NULL;
 }
 
-int pim_upstream_equal(const void *arg1, const void *arg2)
+bool pim_upstream_equal(const void *arg1, const void *arg2)
 {
        const struct pim_upstream *up1 = (const struct pim_upstream *)arg1;
        const struct pim_upstream *up2 = (const struct pim_upstream *)arg2;
 
        if ((up1->sg.grp.s_addr == up2->sg.grp.s_addr)
            && (up1->sg.src.s_addr == up2->sg.src.s_addr))
-               return 1;
+               return true;
 
-       return 0;
+       return false;
 }
 
 /* rfc4601:section-4.2:"Data Packet Forwarding Rules" defines
index ba133b39dd444a3a3508d501049389b9b11fdc4d..a347ab991c98717595259b85e269c062a4f8cc7c 100644 (file)
@@ -223,5 +223,5 @@ void pim_upstream_spt_prefix_list_update(struct pim_instance *pim,
                                         struct prefix_list *pl);
 
 unsigned int pim_upstream_hash_key(void *arg);
-int pim_upstream_equal(const void *arg1, const void *arg2);
+bool pim_upstream_equal(const void *arg1, const void *arg2);
 #endif /* PIM_UPSTREAM_H */
index 518eff3f730092d284e3c9683cc36ca406f9ae5e..4e168e142cc09ef1d5658b3c33b01b5124786eda 100644 (file)
@@ -234,13 +234,13 @@ static unsigned int static_nht_hash_key(void *data)
        return jhash_1word(nhtd->nh_vrf_id, key);
 }
 
-static int static_nht_hash_cmp(const void *d1, const void *d2)
+static bool static_nht_hash_cmp(const void *d1, const void *d2)
 {
        const struct static_nht_data *nhtd1 = d1;
        const struct static_nht_data *nhtd2 = d2;
 
        if (nhtd1->nh_vrf_id != nhtd2->nh_vrf_id)
-               return 0;
+               return false;
 
        return prefix_same(nhtd1->nh, nhtd2->nh);
 }
index 0ccd3242d59dc28411b2aff650605de3c3f450c5..5fe01161586c76fbd44b4a697aed718c26009d76 100644 (file)
@@ -79,7 +79,7 @@ static zebra_fec_t *fec_add(struct route_table *table, struct prefix *p,
 static int fec_del(zebra_fec_t *fec);
 
 static unsigned int label_hash(void *p);
-static int label_cmp(const void *p1, const void *p2);
+static bool label_cmp(const void *p1, const void *p2);
 static int nhlfe_nexthop_active_ipv4(zebra_nhlfe_t *nhlfe,
                                     struct nexthop *nexthop);
 static int nhlfe_nexthop_active_ipv6(zebra_nhlfe_t *nhlfe,
@@ -592,7 +592,7 @@ static unsigned int label_hash(void *p)
 /*
  * Compare 2 LSP hash entries based on in-label.
  */
-static int label_cmp(const void *p1, const void *p2)
+static bool label_cmp(const void *p1, const void *p2)
 {
        const zebra_ile_t *ile1 = p1;
        const zebra_ile_t *ile2 = p2;
index 40f97765da8c84dfa5fff208447a4a854a5b2c2f..1a528780c1ae0db921507b6dbc639cbe188d9183 100644 (file)
@@ -164,7 +164,7 @@ uint32_t zebra_pbr_rules_hash_key(void *arg)
                            jhash_1word(rule->rule.unique, key));
 }
 
-int zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
+bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
 {
        const struct zebra_pbr_rule *r1, *r2;
 
@@ -172,36 +172,36 @@ int zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2)
        r2 = (const struct zebra_pbr_rule *)arg2;
 
        if (r1->rule.seq != r2->rule.seq)
-               return 0;
+               return false;
 
        if (r1->rule.priority != r2->rule.priority)
-               return 0;
+               return false;
 
        if (r1->rule.unique != r2->rule.unique)
-               return 0;
+               return false;
 
        if (r1->rule.action.table != r2->rule.action.table)
-               return 0;
+               return false;
 
        if (r1->rule.filter.src_port != r2->rule.filter.src_port)
-               return 0;
+               return false;
 
        if (r1->rule.filter.dst_port != r2->rule.filter.dst_port)
-               return 0;
+               return false;
 
        if (r1->rule.filter.fwmark != r2->rule.filter.fwmark)
-               return 0;
+               return false;
 
        if (!prefix_same(&r1->rule.filter.src_ip, &r2->rule.filter.src_ip))
-               return 0;
+               return false;
 
        if (!prefix_same(&r1->rule.filter.dst_ip, &r2->rule.filter.dst_ip))
-               return 0;
+               return false;
 
        if (r1->ifp != r2->ifp)
-               return 0;
+               return false;
 
-       return 1;
+       return true;
 }
 
 struct pbr_rule_unique_lookup {
@@ -260,7 +260,7 @@ uint32_t zebra_pbr_ipset_hash_key(void *arg)
        return jhash2(pnt, ZEBRA_IPSET_NAME_HASH_SIZE, 0x63ab42de);
 }
 
-int zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2)
+bool zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2)
 {
        const struct zebra_pbr_ipset *r1, *r2;
 
@@ -268,13 +268,13 @@ int zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2)
        r2 = (const struct zebra_pbr_ipset *)arg2;
 
        if (r1->type != r2->type)
-               return 0;
+               return false;
        if (r1->unique != r2->unique)
-               return 0;
+               return false;
        if (strncmp(r1->ipset_name, r2->ipset_name,
                    ZEBRA_IPSET_NAME_SIZE))
-               return 0;
-       return 1;
+               return false;
+       return true;
 }
 
 void zebra_pbr_ipset_entry_free(void *arg)
@@ -313,7 +313,7 @@ uint32_t zebra_pbr_ipset_entry_hash_key(void *arg)
        return key;
 }
 
-int zebra_pbr_ipset_entry_hash_equal(const void *arg1, const void *arg2)
+bool zebra_pbr_ipset_entry_hash_equal(const void *arg1, const void *arg2)
 {
        const struct zebra_pbr_ipset_entry *r1, *r2;
 
@@ -321,29 +321,29 @@ int zebra_pbr_ipset_entry_hash_equal(const void *arg1, const void *arg2)
        r2 = (const struct zebra_pbr_ipset_entry *)arg2;
 
        if (r1->unique != r2->unique)
-               return 0;
+               return false;
 
        if (!prefix_same(&r1->src, &r2->src))
-               return 0;
+               return false;
 
        if (!prefix_same(&r1->dst, &r2->dst))
-               return 0;
+               return false;
 
        if (r1->src_port_min != r2->src_port_min)
-               return 0;
+               return false;
 
        if (r1->src_port_max != r2->src_port_max)
-               return 0;
+               return false;
 
        if (r1->dst_port_min != r2->dst_port_min)
-               return 0;
+               return false;
 
        if (r1->dst_port_max != r2->dst_port_max)
-               return 0;
+               return false;
 
        if (r1->proto != r2->proto)
-               return 0;
-       return 1;
+               return false;
+       return true;
 }
 
 void zebra_pbr_iptable_free(void *arg)
@@ -389,7 +389,7 @@ uint32_t zebra_pbr_iptable_hash_key(void *arg)
                            iptable->unique, key);
 }
 
-int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2)
+bool zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2)
 {
        const struct zebra_pbr_iptable *r1, *r2;
 
@@ -397,31 +397,31 @@ int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2)
        r2 = (const struct zebra_pbr_iptable *)arg2;
 
        if (r1->type != r2->type)
-               return 0;
+               return false;
        if (r1->unique != r2->unique)
-               return 0;
+               return false;
        if (r1->filter_bm != r2->filter_bm)
-               return 0;
+               return false;
        if (r1->fwmark != r2->fwmark)
-               return 0;
+               return false;
        if (r1->action != r2->action)
-               return 0;
+               return false;
        if (strncmp(r1->ipset_name, r2->ipset_name,
                    ZEBRA_IPSET_NAME_SIZE))
-               return 0;
+               return false;
        if (r1->pkt_len_min != r2->pkt_len_min)
-               return 0;
+               return false;
        if (r1->pkt_len_max != r2->pkt_len_max)
-               return 0;
+               return false;
        if (r1->tcp_flags != r2->tcp_flags)
-               return 0;
+               return false;
        if (r1->tcp_mask_flags != r2->tcp_mask_flags)
-               return 0;
+               return false;
        if (r1->dscp_value != r2->dscp_value)
-               return 0;
+               return false;
        if (r1->fragment != r2->fragment)
-               return 0;
-       return 1;
+               return false;
+       return true;
 }
 
 static void *pbr_rule_alloc_intern(void *arg)
index 3311af4d2644eb7171b51b993f852835fc2119b7..093fcfa8b04ce214f0a159b5e36010b5026260b4 100644 (file)
@@ -213,7 +213,7 @@ extern int kernel_pbr_rule_del(struct zebra_pbr_rule *rule);
 
 extern void zebra_pbr_rules_free(void *arg);
 extern uint32_t zebra_pbr_rules_hash_key(void *arg);
-extern int zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2);
+extern bool zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2);
 
 /* has operates on 32bit pointer
  * and field is a string of 8bit
@@ -222,15 +222,16 @@ extern int zebra_pbr_rules_hash_equal(const void *arg1, const void *arg2);
 
 extern void zebra_pbr_ipset_free(void *arg);
 extern uint32_t zebra_pbr_ipset_hash_key(void *arg);
-extern int zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2);
+extern bool zebra_pbr_ipset_hash_equal(const void *arg1, const void *arg2);
 
 extern void zebra_pbr_ipset_entry_free(void *arg);
 extern uint32_t zebra_pbr_ipset_entry_hash_key(void *arg);
-extern int zebra_pbr_ipset_entry_hash_equal(const void *arg1, const void *arg2);
+extern bool zebra_pbr_ipset_entry_hash_equal(const void *arg1,
+                                            const void *arg2);
 
 extern void zebra_pbr_iptable_free(void *arg);
 extern uint32_t zebra_pbr_iptable_hash_key(void *arg);
-extern int zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2);
+extern bool zebra_pbr_iptable_hash_equal(const void *arg1, const void *arg2);
 
 extern void zebra_pbr_init(void);
 extern void zebra_pbr_show_ipset_list(struct vty *vty, char *ipsetname);
index ab0b175cccbc491362d4b203db6bc9b0ab03b86c..fe182780bebcfba09212a5887be3292f965b7537 100644 (file)
@@ -81,7 +81,6 @@ static int zvni_macip_send_msg_to_client(vni_t vni, struct ethaddr *macaddr,
                                         struct ipaddr *ip, uint8_t flags,
                                         uint32_t seq, uint16_t cmd);
 static unsigned int neigh_hash_keymake(void *p);
-static int neigh_cmp(const void *p1, const void *p2);
 static void *zvni_neigh_alloc(void *p);
 static zebra_neigh_t *zvni_neigh_add(zebra_vni_t *zvni, struct ipaddr *ip,
                                     struct ethaddr *mac);
@@ -137,7 +136,7 @@ static void zebra_vxlan_process_l3vni_oper_up(zebra_l3vni_t *zl3vni);
 static void zebra_vxlan_process_l3vni_oper_down(zebra_l3vni_t *zl3vni);
 
 static unsigned int mac_hash_keymake(void *p);
-static int mac_cmp(const void *p1, const void *p2);
+static bool mac_cmp(const void *p1, const void *p2);
 static void *zvni_mac_alloc(void *p);
 static zebra_mac_t *zvni_mac_add(zebra_vni_t *zvni, struct ethaddr *macaddr);
 static int zvni_mac_del(zebra_vni_t *zvni, zebra_mac_t *mac);
@@ -157,7 +156,6 @@ static int zvni_mac_uninstall(zebra_vni_t *zvni, zebra_mac_t *mac);
 static void zvni_install_mac_hash(struct hash_backet *backet, void *ctxt);
 
 static unsigned int vni_hash_keymake(void *p);
-static int vni_hash_cmp(const void *p1, const void *p2);
 static void *zvni_alloc(void *p);
 static zebra_vni_t *zvni_lookup(vni_t vni);
 static zebra_vni_t *zvni_add(vni_t vni);
@@ -1254,16 +1252,16 @@ static unsigned int neigh_hash_keymake(void *p)
 /*
  * Compare two neighbor hash structures.
  */
-static int neigh_cmp(const void *p1, const void *p2)
+static bool neigh_cmp(const void *p1, const void *p2)
 {
        const zebra_neigh_t *n1 = p1;
        const zebra_neigh_t *n2 = p2;
 
        if (n1 == NULL && n2 == NULL)
-               return 1;
+               return true;
 
        if (n1 == NULL || n2 == NULL)
-               return 0;
+               return false;
 
        return (memcmp(&n1->ip, &n2->ip, sizeof(struct ipaddr)) == 0);
 }
@@ -2240,16 +2238,16 @@ static unsigned int mac_hash_keymake(void *p)
 /*
  * Compare two MAC addresses.
  */
-static int mac_cmp(const void *p1, const void *p2)
+static bool mac_cmp(const void *p1, const void *p2)
 {
        const zebra_mac_t *pmac1 = p1;
        const zebra_mac_t *pmac2 = p2;
 
        if (pmac1 == NULL && pmac2 == NULL)
-               return 1;
+               return true;
 
        if (pmac1 == NULL || pmac2 == NULL)
-               return 0;
+               return false;
 
        return (memcmp(pmac1->macaddr.octet, pmac2->macaddr.octet, ETH_ALEN)
                == 0);
@@ -2761,7 +2759,7 @@ static unsigned int vni_hash_keymake(void *p)
 /*
  * Compare 2 VNI hash entries.
  */
-static int vni_hash_cmp(const void *p1, const void *p2)
+static bool vni_hash_cmp(const void *p1, const void *p2)
 {
        const zebra_vni_t *zvni1 = p1;
        const zebra_vni_t *zvni2 = p2;
@@ -3619,7 +3617,7 @@ static unsigned int l3vni_hash_keymake(void *p)
 /*
  * Compare 2 L3 VNI hash entries.
  */
-static int l3vni_hash_cmp(const void *p1, const void *p2)
+static bool l3vni_hash_cmp(const void *p1, const void *p2)
 {
        const zebra_l3vni_t *zl3vni1 = p1;
        const zebra_l3vni_t *zl3vni2 = p2;