* [PATCH 1/1] mktree: long is bigger on 64-bit (v2)
@ 2009-05-14 2:29 Serge E. Hallyn
[not found] ` <20090514022932.GA29738-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Serge E. Hallyn @ 2009-05-14 2:29 UTC (permalink / raw)
To: Oren Laadan, Nathan T Lynch; +Cc: Linux Containers
mktree's hash function assumes that long is 32 bits. Fix.
This version takes Nathan's suggestion of using sizeof(key)
instead of sizeof(long).
Signed-off-by: Serge Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
mktree.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/mktree.c b/mktree.c
index 7a8cecc..c1f13b8 100644
--- a/mktree.c
+++ b/mktree.c
@@ -1291,7 +1291,7 @@ static void hash_exit(struct ckpt_ctx *ctx)
static inline int hash_func(long key)
{
unsigned long hash = key * GOLDEN_RATIO_PRIME_32;
- return (hash >> (32 - HASH_BITS));
+ return (hash >> (sizeof(key)*8 - HASH_BITS));
}
static int hash_insert(struct ckpt_ctx *ctx, long key, void *data)
--
1.6.1.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-05-14 10:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-14 2:29 [PATCH 1/1] mktree: long is bigger on 64-bit (v2) Serge E. Hallyn
[not found] ` <20090514022932.GA29738-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-05-14 10:12 ` Oren Laadan
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.