From 04523354a50761f9eafb38a1e816587b5100de4f Mon Sep 17 00:00:00 2001 From: Peter Lund Date: Tue, 16 Oct 2007 23:29:35 -0700 Subject: [PATCH] --- yaml --- r: 70664 b: refs/heads/master c: 430d275a399175c7c0673459738979287ec1fd22 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/lib/radix-tree.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/[refs] b/[refs] index 83c315d79fb6..7ed8ab7cd48e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 22e48eaf587d044ba311a73c6fe0d0deaa8fdb63 +refs/heads/master: 430d275a399175c7c0673459738979287ec1fd22 diff --git a/trunk/lib/radix-tree.c b/trunk/lib/radix-tree.c index 53fd44d78716..48c250fe2233 100644 --- a/trunk/lib/radix-tree.c +++ b/trunk/lib/radix-tree.c @@ -1049,12 +1049,14 @@ radix_tree_node_ctor(struct kmem_cache *cachep, void *node) static __init unsigned long __maxindex(unsigned int height) { - unsigned int tmp = height * RADIX_TREE_MAP_SHIFT; - unsigned long index = (~0UL >> (RADIX_TREE_INDEX_BITS - tmp - 1)) >> 1; - - if (tmp >= RADIX_TREE_INDEX_BITS) - index = ~0UL; - return index; + unsigned int width = height * RADIX_TREE_MAP_SHIFT; + int shift = RADIX_TREE_INDEX_BITS - width; + + if (shift < 0) + return ~0UL; + if (shift >= BITS_PER_LONG) + return 0UL; + return ~0UL >> shift; } static __init void radix_tree_init_maxindex(void)