Commit 7f590657 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Linus Torvalds

lib: bitmap: remove redundant code from __bitmap_shift_left

The first of these conditionals is completely redundant: If k == lim-1, we
must have off==0, so the second conditional will also trigger and then it
wouldn't matter if upper had some high bits set.  But the second
conditional is in fact also redundant, since it only serves to clear out
some high-order "don't care" bits of dst, about which no guarantee is
made.
Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6d874eca
...@@ -159,7 +159,7 @@ void __bitmap_shift_left(unsigned long *dst, const unsigned long *src, ...@@ -159,7 +159,7 @@ void __bitmap_shift_left(unsigned long *dst, const unsigned long *src,
unsigned int shift, unsigned int nbits) unsigned int shift, unsigned int nbits)
{ {
int k; int k;
unsigned int lim = BITS_TO_LONGS(nbits), left = nbits % BITS_PER_LONG; unsigned int lim = BITS_TO_LONGS(nbits);
unsigned int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG; unsigned int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG;
for (k = lim - off - 1; k >= 0; --k) { for (k = lim - off - 1; k >= 0; --k) {
unsigned long upper, lower; unsigned long upper, lower;
...@@ -172,13 +172,8 @@ void __bitmap_shift_left(unsigned long *dst, const unsigned long *src, ...@@ -172,13 +172,8 @@ void __bitmap_shift_left(unsigned long *dst, const unsigned long *src,
lower = src[k - 1] >> (BITS_PER_LONG - rem); lower = src[k - 1] >> (BITS_PER_LONG - rem);
else else
lower = 0; lower = 0;
upper = src[k]; upper = src[k] << rem;
if (left && k == lim - 1)
upper &= (1UL << left) - 1;
upper <<= rem;
dst[k + off] = lower | upper; dst[k + off] = lower | upper;
if (left && k + off == lim - 1)
dst[k + off] &= (1UL << left) - 1;
} }
if (off) if (off)
memset(dst, 0, off*sizeof(unsigned long)); memset(dst, 0, off*sizeof(unsigned long));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment