[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64N.0708291232130.26167@blysk.ds.pg.gda.pl>
Date: Wed, 29 Aug 2007 12:39:16 +0100 (BST)
From: "Maciej W. Rozycki" <macro@...ux-mips.org>
To: Christoph Hellwig <hch@...radead.org>
cc: Peter Firefly Lund <firefly@...64.dk>,
Christoph Lameter <clameter@....com>,
Momchil Velikov <velco@...ata.bg>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] avoid negative shifts in radix-tree.c
On Mon, 27 Aug 2007, Christoph Hellwig wrote:
> The conceptual change looks fine to me, but the code looks a little odd,
> what about:
>
> static __init unsigned long __maxindex(unsigned int height)
> {
> unsigned int tmp = height * RADIX_TREE_MAP_SHIFT;
> int shift = RADIX_TREE_INDEX_BITS - tmp;
>
> if (shift < 0)
> return ~0UL;
> return ~0UL >> shift;
> }
>
> instead?
This patch has been successfully tested on actual hardware (VAXstation
4000/90). If nobody objects, I'll push it to Andrew.
Maciej
Signed-off-by: Maciej W. Rozycki <macro@...ux-mips.org>
patch-vax-2.6.17-rc4-20070111-radix-maxindex-0
diff -up --recursive --new-file linux-vax-2.6.17-rc4-20070111.macro/lib/radix-tree.c linux-vax-2.6.17-rc4-20070111/lib/radix-tree.c
--- linux-vax-2.6.17-rc4-20070111.macro/lib/radix-tree.c 2006-10-31 19:05:50.000000000 +0000
+++ linux-vax-2.6.17-rc4-20070111/lib/radix-tree.c 2007-01-22 01:24:17.000000000 +0000
@@ -825,9 +825,11 @@ radix_tree_node_ctor(void *node, kmem_ca
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;
+ unsigned long index;
- if (tmp >= RADIX_TREE_INDEX_BITS)
+ if (tmp < RADIX_TREE_INDEX_BITS)
+ index = (~0UL >> (RADIX_TREE_INDEX_BITS - tmp - 1)) >> 1;
+ else
index = ~0UL;
return index;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists