Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: shemminger@vyatta.com (Stephen Hemminger)
Subject: [ltt-dev] [PATCH] lfhash: constify arguments to compare and hash function
Date: Tue, 15 Nov 2011 20:24:05 -0800	[thread overview]
Message-ID: <20111115202405.0fd07e1d@nehalam.linuxnetplumber.net> (raw)


The compare and hash functions do not modify key.
---
 tests/test_urcu_hash.c |    8 ++++----
 urcu/rculfhash.h       |    8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/test_urcu_hash.c b/tests/test_urcu_hash.c
index 88dd1ae..f45c492 100644
--- a/tests/test_urcu_hash.c
+++ b/tests/test_urcu_hash.c
@@ -295,7 +295,7 @@ void hashword2(
 
 #if (CAA_BITS_PER_LONG == 32)
 static
-unsigned long test_hash(void *_key, size_t length, unsigned long seed)
+unsigned long test_hash(const void *_key, size_t length, unsigned long seed)
 {
 	unsigned long key = (unsigned long) _key;
 	unsigned long v;
@@ -305,7 +305,7 @@ unsigned long test_hash(void *_key, size_t length, unsigned long seed)
 }
 #else
 static
-unsigned long test_hash(void *_key, size_t length, unsigned long seed)
+unsigned long test_hash(const void *_key, size_t length, unsigned long seed)
 {
 	union {
 		uint64_t v64;
@@ -325,8 +325,8 @@ unsigned long test_hash(void *_key, size_t length, unsigned long seed)
 #endif
 
 static
-unsigned long test_compare(void *key1, size_t key1_len,
-                           void *key2, size_t key2_len)
+unsigned long test_compare(const void *key1, size_t key1_len,
+                           const void *key2, size_t key2_len)
 {
 	if (unlikely(key1_len != key2_len))
 		return -1;
diff --git a/urcu/rculfhash.h b/urcu/rculfhash.h
index 37e36b7..4638d28 100644
--- a/urcu/rculfhash.h
+++ b/urcu/rculfhash.h
@@ -56,10 +56,10 @@ struct cds_lfht;
  * Ensure reader and writer threads are registered as urcu readers.
  */
 
-typedef unsigned long (*cds_lfht_hash_fct)(void *key, size_t length,
-					unsigned long seed);
-typedef unsigned long (*cds_lfht_compare_fct)(void *key1, size_t key1_len,
-					void *key2, size_t key2_len);
+typedef unsigned long (*cds_lfht_hash_fct)(const void *key, size_t length,
+					   unsigned long seed);
+typedef unsigned long (*cds_lfht_compare_fct)(const void *key1, size_t key1_len,
+					      const void *key2, size_t key2_len);
 
 /*
  * cds_lfht_node_init - initialize a hash table node
-- 
1.7.7.1





             reply	other threads:[~2011-11-16  4:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-16  4:24 Stephen Hemminger [this message]
2011-11-16 12:28 ` Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111115202405.0fd07e1d@nehalam.linuxnetplumber.net \
    --to=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox