From 74df8d6d9d665784b0273151fe04cd2f9ff5b353 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 17 Oct 2018 15:27:12 -0400 Subject: *: 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 --- nhrpd/nhrp_cache.c | 4 +++- nhrpd/nhrp_peer.c | 3 ++- nhrpd/nhrp_vc.c | 3 ++- nhrpd/reqid.c | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) (limited to 'nhrpd') diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c index f3a33eb28..1316a4aad 100644 --- a/nhrpd/nhrp_cache.c +++ b/nhrpd/nhrp_cache.c @@ -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); } diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c index 203d4aa98..db2f72ac2 100644 --- a/nhrpd/nhrp_peer.c +++ b/nhrpd/nhrp_peer.c @@ -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; } diff --git a/nhrpd/nhrp_vc.c b/nhrpd/nhrp_vc.c index 41a87d4ad..79a655396 100644 --- a/nhrpd/nhrp_vc.c +++ b/nhrpd/nhrp_vc.c @@ -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); } diff --git a/nhrpd/reqid.c b/nhrpd/reqid.c index e8ad518e5..08a007bdf 100644 --- a/nhrpd/reqid.c +++ b/nhrpd/reqid.c @@ -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; } -- cgit v1.2.3