All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: stable-2.02 - cleanup: better expressing passing key arg to _hash
Date: Fri, 16 Oct 2020 19:11:05 +0000 (GMT)	[thread overview]
Message-ID: <20201016191105.4FED3396EC06@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0bd9eb80c9037da729891ab1bee4d6026ac4a5ac
Commit:        0bd9eb80c9037da729891ab1bee4d6026ac4a5ac
Parent:        f0c281f9a94dead2e32737f69f5e42a757433900
Author:        Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate:    Sat Aug 29 22:37:17 2020 +0200
Committer:     Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Fri Oct 16 16:02:06 2020 +0200

cleanup: better expressing passing key arg to _hash

---
 libdm/datastruct/hash.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libdm/datastruct/hash.c b/libdm/datastruct/hash.c
index 992f4fad9..3e4adfdc0 100644
--- a/libdm/datastruct/hash.c
+++ b/libdm/datastruct/hash.c
@@ -57,26 +57,27 @@ static unsigned char _nums[] = {
 	209
 };
 
-static struct dm_hash_node *_create_node(const char *str, unsigned len)
+static struct dm_hash_node *_create_node(const void *key, unsigned len)
 {
 	struct dm_hash_node *n = dm_malloc(sizeof(*n) + len);
 
 	if (n) {
-		memcpy(n->key, str, len);
+		memcpy(n->key, key, len);
 		n->keylen = len;
 	}
 
 	return n;
 }
 
-static unsigned long _hash(const char *str, unsigned len)
+static unsigned long _hash(const void *key, unsigned len)
 {
+	const unsigned char *str = key;
 	unsigned long h = 0, g;
 	unsigned i;
 
 	for (i = 0; i < len; i++) {
 		h <<= 4;
-		h += _nums[(unsigned char) *str++];
+		h += _nums[*str++];
 		g = h & ((unsigned long) 0xf << 16u);
 		if (g) {
 			h ^= g >> 16u;



                 reply	other threads:[~2020-10-16 19:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20201016191105.4FED3396EC06@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.