summaryrefslogtreecommitdiff
path: root/bgpd/bgp_attr.c
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-08-14 16:25:25 +0100
committerPaul Jakma <paul@quagga.net>2008-08-22 19:52:58 +0100
commitffe11cfb0a808ae514193438616dfabc512b4cf6 (patch)
tree94452dba2c1a49d6e6a0782c6513acb36823cefc /bgpd/bgp_attr.c
parent9fd4958a4eef88c536e4a5aeefce302e10ee8ee6 (diff)
[lib] hash compare function arguments ought to be const qualified
2008-08-14 Stephen Hemminger <stephen.hemminger@vyatta.com> * lib/hash.h: (struct hash) Hash comparator callback really ought to treat storage behind arguments as constant - a compare function with side-effects would be evil. * */*.c: Adjust comparator functions similarly, thus fixing at least a few compiler warnings about const qualifier being dropped. Signed-off-by: Paul Jakma <paul@quagga.net>
Diffstat (limited to 'bgpd/bgp_attr.c')
-rw-r--r--bgpd/bgp_attr.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 752099d1..6f139742 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -131,15 +131,13 @@ cluster_hash_key_make (void *p)
}
static int
-cluster_hash_cmp (void *p1, void *p2)
+cluster_hash_cmp (const void *p1, const void *p2)
{
- struct cluster_list * cluster1 = (struct cluster_list *) p1;
- struct cluster_list * cluster2 = (struct cluster_list *) p2;
+ const struct cluster_list * cluster1 = p1;
+ const struct cluster_list * cluster2 = p2;
- if (cluster1->length == cluster2->length &&
- memcmp (cluster1->list, cluster2->list, cluster1->length) == 0)
- return 1;
- return 0;
+ return (cluster1->length == cluster2->length &&
+ memcmp (cluster1->list, cluster2->list, cluster1->length) == 0);
}
static void
@@ -267,15 +265,13 @@ transit_hash_key_make (void *p)
}
static int
-transit_hash_cmp (void *p1, void *p2)
+transit_hash_cmp (const void *p1, const void *p2)
{
- struct transit * transit1 = (struct transit *) p1;
- struct transit * transit2 = (struct transit *) p2;
+ const struct transit * transit1 = p1;
+ const struct transit * transit2 = p2;
- if (transit1->length == transit2->length &&
- memcmp (transit1->val, transit2->val, transit1->length) == 0)
- return 1;
- return 0;
+ return (transit1->length == transit2->length &&
+ memcmp (transit1->val, transit2->val, transit1->length) == 0);
}
static void
@@ -393,10 +389,10 @@ attrhash_key_make (void *p)
}
int
-attrhash_cmp (void *p1, void *p2)
+attrhash_cmp (const void *p1, const void *p2)
{
- struct attr * attr1 = (struct attr *) p1;
- struct attr * attr2 = (struct attr *) p2;
+ const struct attr * attr1 = p1;
+ const struct attr * attr2 = p2;
if (attr1->flag == attr2->flag
&& attr1->origin == attr2->origin
@@ -408,8 +404,8 @@ attrhash_cmp (void *p1, void *p2)
&& attr1->pathlimit.ttl == attr2->pathlimit.ttl
&& attr1->pathlimit.as == attr2->pathlimit.as)
{
- struct attr_extra *ae1 = attr1->extra;
- struct attr_extra *ae2 = attr2->extra;
+ const struct attr_extra *ae1 = attr1->extra;
+ const struct attr_extra *ae2 = attr2->extra;
if (ae1 && ae2
&& ae1->aggregator_as == ae2->aggregator_as
@@ -435,7 +431,7 @@ attrhash_cmp (void *p1, void *p2)
}
static void
-attrhash_init ()
+attrhash_init (void)
{
attrhash = hash_create (attrhash_key_make, attrhash_cmp);
}