public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH]  Make `hash_long' function work if bits parameter is 0.
@ 2002-12-06  9:33 Miles Bader
  2002-12-06 16:37 ` Linus Torvalds
  0 siblings, 1 reply; 5+ messages in thread
From: Miles Bader @ 2002-12-06  9:33 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

If the bits parameter of hash_long (in <linux/hash.h>) is 0, then it
ends up right-shifting by BITS_PER_LONG, which is undefined in C (and
often is a nop).

This patch just handles that case explicitly.

diff -ruN -X../cludes ../orig/linux-2.5.50-uc0/include/linux/hash.h include/linux/hash.h
--- ../orig/linux-2.5.50-uc0/include/linux/hash.h	2002-09-18 09:59:18.000000000 +0900
+++ include/linux/hash.h	2002-12-06 13:22:00.000000000 +0900
@@ -27,6 +27,9 @@
 {
 	unsigned long hash = val;
 
+	if (bits == 0)
+		return 0;
+
 #if BITS_PER_LONG == 64
 	/*  Sigh, gcc can't optimise this alone like it does for 32 bits. */
 	unsigned long n = hash;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-12-08 17:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-06  9:33 [PATCH] Make `hash_long' function work if bits parameter is 0 Miles Bader
2002-12-06 16:37 ` Linus Torvalds
2002-12-06 17:58   ` Miles Bader
2002-12-06 18:16     ` Linus Torvalds
2002-12-08 17:23   ` Rogier Wolff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox