diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-10-17 21:27:12 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-10-19 19:14:45 +0200 |
commit | 74df8d6d9d665784b0273151fe04cd2f9ff5b353 (patch) | |
tree | 7b0d38ba7c6e9605634d40a64c4b904295d59d80 /lib | |
parent | *: Fixup to use proper list_cmp functions (diff) | |
download | frr-74df8d6d9d665784b0273151fe04cd2f9ff5b353.tar.xz frr-74df8d6d9d665784b0273151fe04cd2f9ff5b353.zip |
*: Replace hash_cmp function return value to a bool
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/command.c | 2 | ||||
-rw-r--r-- | lib/distribute.c | 10 | ||||
-rw-r--r-- | lib/ferr.c | 2 | ||||
-rw-r--r-- | lib/hash.c | 4 | ||||
-rw-r--r-- | lib/hash.h | 7 | ||||
-rw-r--r-- | lib/if_rmap.c | 2 | ||||
-rw-r--r-- | lib/qobj.c | 2 | ||||
-rw-r--r-- | lib/routemap.c | 13 | ||||
-rw-r--r-- | lib/table.c | 2 | ||||
-rw-r--r-- | lib/thread.c | 4 | ||||
-rw-r--r-- | lib/vrf.c | 2 |
11 files changed, 25 insertions, 25 deletions
diff --git a/lib/command.c b/lib/command.c index 6fe4ae2d8..839c37b10 100644 --- a/lib/command.c +++ b/lib/command.c @@ -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; } diff --git a/lib/distribute.c b/lib/distribute.c index 25fcd9258..0f1d666ae 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -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) { diff --git a/lib/ferr.c b/lib/ferr.c index bf89cc7f4..e18597afb 100644 --- a/lib/ferr.c +++ b/lib/ferr.c @@ -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; diff --git a/lib/hash.c b/lib/hash.c index 114522a75..641c75136 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -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); diff --git a/lib/hash.h b/lib/hash.h index 2b4ea48f3..45ae6ce60 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -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. diff --git a/lib/if_rmap.c b/lib/if_rmap.c index 2c686ecb8..108ab7ec6 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -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; diff --git a/lib/qobj.c b/lib/qobj.c index c3f1a27c8..811645f3c 100644 --- a/lib/qobj.c +++ b/lib/qobj.c @@ -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; diff --git a/lib/routemap.c b/lib/routemap.c index 3a20ed5cd..1814bfc1b 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -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, diff --git a/lib/table.c b/lib/table.c index 3adb79389..0026b7692 100644 --- a/lib/table.c +++ b/lib/table.c @@ -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; diff --git a/lib/thread.c b/lib/thread.c index 267dcd1cf..d104c4f59 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -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"); @@ -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; |