diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-05-14 22:19:07 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-05-14 23:23:08 +0200 |
commit | d8b87afe7c5fcee9caaef7124d5bcd5f0c3af8a1 (patch) | |
tree | ca07ea6097ec12120806ff4c7bd268b9fc063842 /pbrd/pbr_nht.c | |
parent | Merge pull request #4335 from opensourcerouting/zebra-fpm-blackhole-info (diff) | |
download | frr-d8b87afe7c5fcee9caaef7124d5bcd5f0c3af8a1.tar.xz frr-d8b87afe7c5fcee9caaef7124d5bcd5f0c3af8a1.zip |
lib: hashing functions should take const arguments
It doesn't make much sense for a hash function to modify its argument,
so const the hash input.
BGP does it in a couple places, those cast away the const. Not great but
not any worse than it was.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'pbrd/pbr_nht.c')
-rw-r--r-- | pbrd/pbr_nht.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index 750475272..52506542b 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -129,10 +129,10 @@ static void pbr_nh_delete_iterate(struct hash_bucket *b, void *p) pbr_nh_delete((struct pbr_nexthop_cache **)&b->data); } -static uint32_t pbr_nh_hash_key(void *arg) +static uint32_t pbr_nh_hash_key(const void *arg) { uint32_t key; - struct pbr_nexthop_cache *pbrnc = (struct pbr_nexthop_cache *)arg; + const struct pbr_nexthop_cache *pbrnc = arg; key = nexthop_hash(pbrnc->nexthop); @@ -789,10 +789,9 @@ void pbr_nht_nexthop_interface_update(struct interface *ifp) ifp); } -static uint32_t pbr_nhg_hash_key(void *arg) +static uint32_t pbr_nhg_hash_key(const void *arg) { - struct pbr_nexthop_group_cache *nhgc = - (struct pbr_nexthop_group_cache *)arg; + const struct pbr_nexthop_group_cache *nhgc = arg; return jhash(&nhgc->name, strlen(nhgc->name), 0x52c34a96); } @@ -940,7 +939,7 @@ void pbr_nht_init(void) pbr_nhg_hash = hash_create_size( 16, pbr_nhg_hash_key, pbr_nhg_hash_equal, "PBR NHG Cache Hash"); pbr_nhrc_hash = - hash_create_size(16, (unsigned int (*)(void *))nexthop_hash, + hash_create_size(16, (unsigned int (*)(const void *))nexthop_hash, pbr_nhrc_hash_equal, "PBR NH Hash"); pbr_nhg_low_table = PBR_NHT_DEFAULT_LOW_TABLEID; |