]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd, isisd, lib: Make key values const for skiplist
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sun, 22 Mar 2020 02:56:03 +0000 (22:56 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 24 Mar 2020 11:33:13 +0000 (07:33 -0400)
Make some key values const for the skiplist code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
14 files changed:
bgpd/rfapi/rfapi_ap.c
bgpd/rfapi/rfapi_import.c
bgpd/rfapi/rfapi_monitor.c
bgpd/rfapi/rfapi_nve_addr.c
bgpd/rfapi/rfapi_nve_addr.h
bgpd/rfapi/rfapi_rib.c
bgpd/rfapi/rfapi_rib.h
bgpd/rfapi/rfapi_vty.c
bgpd/rfapi/vnc_import_bgp.c
bgpd/rfapi/vnc_import_bgp.h
isisd/fabricd.c
isisd/isis_spf_private.h
lib/skiplist.c
lib/skiplist.h

index c5fda15d33fc03c43e38b4346afcc33d99b0dd38..abb18aeb2c8ff259338f4fced8c828db076c35d4 100644 (file)
  * is used to spread out the sort for adbs with the same lifetime
  * and thereby make the skip list operations more efficient.
  */
-static int sl_adb_lifetime_cmp(void *adb1, void *adb2)
+static int sl_adb_lifetime_cmp(const void *adb1, const void *adb2)
 {
-       struct rfapi_adb *a1 = adb1;
-       struct rfapi_adb *a2 = adb2;
+       const struct rfapi_adb *a1 = adb1;
+       const struct rfapi_adb *a2 = adb2;
 
        if (a1->lifetime < a2->lifetime)
                return -1;
index 5cb4fd5a1086318ba17d7ffaccc416f8e4c398ca..6c50092e6a602bd1aed706190f383083483278c2 100644 (file)
@@ -2006,10 +2006,10 @@ static void rfapiBgpInfoDetach(struct agg_node *rn, struct bgp_path_info *bpi)
 /*
  * For L3-indexed import tables
  */
-static int rfapi_bi_peer_rd_cmp(void *b1, void *b2)
+static int rfapi_bi_peer_rd_cmp(const void *b1, const void *b2)
 {
-       struct bgp_path_info *bpi1 = b1;
-       struct bgp_path_info *bpi2 = b2;
+       const struct bgp_path_info *bpi1 = b1;
+       const struct bgp_path_info *bpi2 = b2;
 
        /*
         * Compare peers
@@ -2022,8 +2022,9 @@ static int rfapi_bi_peer_rd_cmp(void *b1, void *b2)
        /*
         * compare RDs
         */
-       return vnc_prefix_cmp((struct prefix *)&bpi1->extra->vnc.import.rd,
-                             (struct prefix *)&bpi2->extra->vnc.import.rd);
+       return vnc_prefix_cmp(
+               (const struct prefix *)&bpi1->extra->vnc.import.rd,
+               (const struct prefix *)&bpi2->extra->vnc.import.rd);
 }
 
 /*
@@ -2031,10 +2032,10 @@ static int rfapi_bi_peer_rd_cmp(void *b1, void *b2)
  * The BPIs in these tables should ALWAYS have an aux_prefix set because
  * they arrive via IPv4 or IPv6 advertisements.
  */
-static int rfapi_bi_peer_rd_aux_cmp(void *b1, void *b2)
+static int rfapi_bi_peer_rd_aux_cmp(const void *b1, const void *b2)
 {
-       struct bgp_path_info *bpi1 = b1;
-       struct bgp_path_info *bpi2 = b2;
+       const struct bgp_path_info *bpi1 = b1;
+       const struct bgp_path_info *bpi2 = b2;
        int rc;
 
        /*
index dc1f7e0fbb80164af28b13472f44fb4b7a00a72b..74094efdf38497f9cac73940be96f10b518b6a49 100644 (file)
@@ -1103,10 +1103,10 @@ static void rfapiMonitorEthTimerRestart(struct rfapi_monitor_eth *m)
                         m->rfd->response_lifetime, &m->timer);
 }
 
-static int mon_eth_cmp(void *a, void *b)
+static int mon_eth_cmp(const void *a, const void *b)
 {
-       struct rfapi_monitor_eth *m1;
-       struct rfapi_monitor_eth *m2;
+       const struct rfapi_monitor_eth *m1;
+       const struct rfapi_monitor_eth *m2;
 
        int i;
 
index ee54d88c3f46bb82fccea30b9ccb94c1e76f2b66..b8193f14313dcbdf63054507e74491ed606cf2f3 100644 (file)
@@ -58,10 +58,10 @@ static void logdifferent(const char *tag, struct rfapi_nve_addr *a,
 #endif
 
 
-int rfapi_nve_addr_cmp(void *k1, void *k2)
+int rfapi_nve_addr_cmp(const void *k1, const void *k2)
 {
-       struct rfapi_nve_addr *a = (struct rfapi_nve_addr *)k1;
-       struct rfapi_nve_addr *b = (struct rfapi_nve_addr *)k2;
+       const struct rfapi_nve_addr *a = (struct rfapi_nve_addr *)k1;
+       const struct rfapi_nve_addr *b = (struct rfapi_nve_addr *)k2;
        int ret = 0;
 
        if (!a || !b) {
index 2d54d4a3ccb2d292b642a0b769e949391938565f..7bcb3cab6984074c0e989422503e98b39d43666c 100644 (file)
@@ -30,7 +30,7 @@ struct rfapi_nve_addr {
 };
 
 
-extern int rfapi_nve_addr_cmp(void *k1, void *k2);
+extern int rfapi_nve_addr_cmp(const void *k1, const void *k2);
 
 extern void rfapiNveAddr2Str(struct rfapi_nve_addr *na, char *buf, int bufsize);
 
index 3d4bdef75a5229c0d68adbf56322643b079fe7c3..141fb03d3604fdaba317824f966764c9d1b83093 100644 (file)
@@ -388,10 +388,10 @@ extern void rfapi_rib_key_init(struct prefix *prefix, /* may be NULL */
 /*
  * Compares two <struct rfapi_rib_key>s
  */
-int rfapi_rib_key_cmp(void *k1, void *k2)
+int rfapi_rib_key_cmp(const void *k1, const void *k2)
 {
-       struct rfapi_rib_key *a = (struct rfapi_rib_key *)k1;
-       struct rfapi_rib_key *b = (struct rfapi_rib_key *)k2;
+       const struct rfapi_rib_key *a = (struct rfapi_rib_key *)k1;
+       const struct rfapi_rib_key *b = (struct rfapi_rib_key *)k2;
        int ret;
 
        if (!a || !b)
index 38a6df9fbf80d85859468c3e75b24970e576795e..3ad021b4f40ce973737fd6b8b8df170c945518a2 100644 (file)
@@ -147,7 +147,7 @@ extern void rfapi_rib_key_init(struct prefix *prefix, /* may be NULL */
                               struct prefix *aux,    /* may be NULL */
                               struct rfapi_rib_key *rk);
 
-extern int rfapi_rib_key_cmp(void *k1, void *k2);
+extern int rfapi_rib_key_cmp(const void *k1, const void *k2);
 
 extern void rfapiAdbFree(struct rfapi_adb *adb);
 
index b18c9e07b56bb8f02a29e8b8cb434e67a75caca1..aa9c216959cbc64101b210f4bf18395ae78890c0 100644 (file)
@@ -2754,10 +2754,10 @@ static void nve_addr_free(void *hap)
        XFREE(MTYPE_RFAPI_NVE_ADDR, hap);
 }
 
-static int nve_addr_cmp(void *k1, void *k2)
+static int nve_addr_cmp(const void *k1, const void *k2)
 {
-       struct nve_addr *a = (struct nve_addr *)k1;
-       struct nve_addr *b = (struct nve_addr *)k2;
+       const struct nve_addr *a = (struct nve_addr *)k1;
+       const struct nve_addr *b = (struct nve_addr *)k2;
        int ret = 0;
 
        if (!a || !b) {
index ba6ef142579d450f3e67eb1d081c48c292928871..d5e509d30d143dee4f1c5c29684dded87f08b6df 100644 (file)
@@ -128,14 +128,14 @@ struct prefix_bag {
 static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0,
                                  0xf8, 0xfc, 0xfe, 0xff};
 
-int vnc_prefix_cmp(void *pfx1, void *pfx2)
+int vnc_prefix_cmp(const void *pfx1, const void *pfx2)
 {
        int offset;
        int shift;
        uint8_t mask;
 
-       struct prefix *p1 = pfx1;
-       struct prefix *p2 = pfx2;
+       const struct prefix *p1 = pfx1;
+       const struct prefix *p2 = pfx2;
 
        if (p1->family < p2->family)
                return -1;
index 3db6f4010a12e761f97db460596dd79aba94b8b2..ca64e6eacc56e1622d30c0974a573517c84c598f 100644 (file)
@@ -32,7 +32,7 @@
 
 extern uint32_t calc_local_pref(struct attr *attr, struct peer *peer);
 
-extern int vnc_prefix_cmp(void *pfx1, void *pfx2);
+extern int vnc_prefix_cmp(const void *pfx1, const void *pfx2);
 
 extern void vnc_import_bgp_add_route(struct bgp *bgp, struct prefix *prefix,
                                     struct bgp_path_info *info);
index b9c27d51bd89d0dc6aeac9fe32b98844cc500f0b..28cc65380fd4aabe37f67c4eabcac7bae8bfc7c1 100644 (file)
@@ -122,9 +122,9 @@ static bool neighbor_entry_hash_cmp(const void *a, const void *b)
        return memcmp(na->id, nb->id, sizeof(na->id)) == 0;
 }
 
-static int neighbor_entry_list_cmp(void *a, void *b)
+static int neighbor_entry_list_cmp(const void *a, const void *b)
 {
-       struct neighbor_entry *na = a, *nb = b;
+       const struct neighbor_entry *na = a, *nb = b;
 
        return -memcmp(na->id, nb->id, sizeof(na->id));
 }
index a8185a8be0fec76b0a5170457d87d453e9f9d503..05aae14b94e8e888c1cc8758d0fda2646d335803 100644 (file)
@@ -117,11 +117,11 @@ static bool isis_vertex_queue_hash_cmp(const void *a, const void *b)
  * Compares vertizes for sorting in the TENT list. Returns true
  * if candidate should be considered before current, false otherwise.
  */
-__attribute__((__unused__))
-static int isis_vertex_queue_tent_cmp(void *a, void *b)
+__attribute__((__unused__)) static int isis_vertex_queue_tent_cmp(const void *a,
+                                                                 const void *b)
 {
-       struct isis_vertex *va = a;
-       struct isis_vertex *vb = b;
+       const struct isis_vertex *va = a;
+       const struct isis_vertex *vb = b;
 
        if (va->d_N < vb->d_N)
                return -1;
index d955c6eb9e61bc275b417a58dccadf478cee7a0d..fa25770efacfbb53c8677b436318f2618911452f 100644 (file)
@@ -112,7 +112,7 @@ static int randomLevel(void)
        return level;
 }
 
-static int default_cmp(void *key1, void *key2)
+static int default_cmp(const void *key1, const void *key2)
 {
        if (key1 < key2)
                return -1;
@@ -126,7 +126,8 @@ unsigned int skiplist_count(struct skiplist *l)
        return l->count;
 }
 
-struct skiplist *skiplist_new(int flags, int (*cmp)(void *key1, void *key2),
+struct skiplist *skiplist_new(int flags,
+                             int (*cmp)(const void *key1, const void *key2),
                              void (*del)(void *val))
 {
        struct skiplist *new;
@@ -329,8 +330,8 @@ int skiplist_delete(register struct skiplist *l, register void *key,
  * Also set a cursor for use with skiplist_next_value.
  */
 int skiplist_first_value(register struct skiplist *l, /* in */
-                        register void *key,      /* in */
-                        void **valuePointer,    /* out */
+                        register const void *key,    /* in */
+                        void **valuePointer,         /* out */
                         void **cursor)               /* out */
 {
        register int k;
@@ -374,7 +375,7 @@ int skiplist_search(register struct skiplist *l, register void *key,
  * last element with the given key, -1 is returned.
  */
 int skiplist_next_value(register struct skiplist *l, /* in */
-                       register void *key,       /* in */
+                       register const void *key,         /* in */
                        void **valuePointer,     /* in/out */
                        void **cursor)               /* in/out */
 {
index 2ab37331c9a9c8e96c1946ff3dcccf57d4299fb0..a106a455d6c271075e754554ed87bc14c734218c 100644 (file)
@@ -68,7 +68,7 @@ struct skiplist {
         * Returns -1 if val1 < val2, 0 if equal?, 1 if val1 > val2.
         * Used as definition of sorted for listnode_add_sort
         */
-       int (*cmp)(void *val1, void *val2);
+       int (*cmp)(const void *val1, const void *val2);
 
        /* callback to free user-owned data when listnode is deleted. supplying
         * this callback is very much encouraged!
@@ -81,8 +81,9 @@ struct skiplist {
 extern struct skiplist *
 skiplist_new(/* encouraged: set list.del callback on new lists */
             int flags,
-            int (*cmp)(void *key1, void *key2), /* NULL => default cmp */
-            void (*del)(void *val));            /* NULL => no auto val free */
+            int (*cmp)(const void *key1,
+                       const void *key2), /* NULL => default cmp */
+            void (*del)(void *val));      /* NULL => no auto val free */
 
 extern void skiplist_free(struct skiplist *);
 
@@ -96,12 +97,12 @@ extern int skiplist_search(register struct skiplist *l, register void *key,
                           void **valuePointer);
 
 extern int skiplist_first_value(register struct skiplist *l, /* in */
-                               register void *key,       /* in */
-                               void **valuePointer,     /* in/out */
+                               register const void *key,    /* in */
+                               void **valuePointer,         /* in/out */
                                void **cursor);              /* out */
 
 extern int skiplist_next_value(register struct skiplist *l, /* in */
-                              register void *key,        /* in */
+                              register const void *key,          /* in */
                               void **valuePointer,      /* in/out */
                               void **cursor);              /* in/out */