[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>
diff --git a/lib/thread.c b/lib/thread.c
index 095dff4..260e8c8 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -223,8 +223,8 @@
}
static int
-cpu_record_hash_cmp (struct cpu_thread_history *a,
- struct cpu_thread_history *b)
+cpu_record_hash_cmp (const struct cpu_thread_history *a,
+ const struct cpu_thread_history *b)
{
return a->func == b->func;
}
@@ -410,7 +410,7 @@
if (cpu_record == NULL)
cpu_record
= hash_create_size (1011, (unsigned int (*) (void *))cpu_record_hash_key,
- (int (*) (void *, void *))cpu_record_hash_cmp);
+ (int (*) (const void *, const void *))cpu_record_hash_cmp);
return (struct thread_master *) XCALLOC (MTYPE_THREAD_MASTER,
sizeof (struct thread_master));