]> git.proxmox.com Git - mirror_frr.git/blobdiff - nhrpd/reqid.c
lib: hashing functions should take const arguments
[mirror_frr.git] / nhrpd / reqid.c
index 61fbfd7795d663454c94099287393df5bc98b89e..e56bbe3bf779b238c7598a4c66f1bc100bd8a492 100644 (file)
@@ -2,28 +2,32 @@
 #include "hash.h"
 #include "nhrpd.h"
 
-static unsigned int nhrp_reqid_key(void *data)
+static unsigned int nhrp_reqid_key(const void *data)
 {
-       struct nhrp_reqid *r = data;
+       const struct nhrp_reqid *r = 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;
 }
 
-uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *p, struct nhrp_reqid *r, void (*cb)(struct nhrp_reqid *, void *))
+uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *p, struct nhrp_reqid *r,
+                         void (*cb)(struct nhrp_reqid *, void *))
 {
        if (!p->reqid_hash) {
-               p->reqid_hash = hash_create(nhrp_reqid_key, nhrp_reqid_cmp, NULL);
+               p->reqid_hash = hash_create(nhrp_reqid_key, nhrp_reqid_cmp,
+                                           "NHRP reqid Hash");
                p->next_request_id = 1;
        }
 
        if (r->cb != cb) {
                r->request_id = p->next_request_id;
-               if (++p->next_request_id == 0) p->next_request_id = 1;
+               if (++p->next_request_id == 0)
+                       p->next_request_id = 1;
                r->cb = cb;
                hash_get(p->reqid_hash, r, hash_alloc_intern);
        }
@@ -41,9 +45,8 @@ void nhrp_reqid_free(struct nhrp_reqid_pool *p, struct nhrp_reqid *r)
 struct nhrp_reqid *nhrp_reqid_lookup(struct nhrp_reqid_pool *p, uint32_t reqid)
 {
        struct nhrp_reqid key;
-       if (!p->reqid_hash) return 0;
+       if (!p->reqid_hash)
+               return 0;
        key.request_id = reqid;
        return hash_lookup(p->reqid_hash, &key);
 }
-
-