aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2015-02-13 17:36:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 00:21:35 -0500
commit7f590657937f1c59163ff14a13062439a18e4a37 (patch)
treec07798a14a2394d7fc7771e1baa95b90e63539bc /lib
parent6d874eca6595629258a5d9af237c5ae53a9544e1 (diff)
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: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/bitmap.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 36e380da00c5..a13c7f4e325a 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -159,7 +159,7 @@ void __bitmap_shift_left(unsigned long *dst, const unsigned long *src,
159 unsigned int shift, unsigned int nbits) 159 unsigned int shift, unsigned int nbits)
160{ 160{
161 int k; 161 int k;
162 unsigned int lim = BITS_TO_LONGS(nbits), left = nbits % BITS_PER_LONG; 162 unsigned int lim = BITS_TO_LONGS(nbits);
163 unsigned int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG; 163 unsigned int off = shift/BITS_PER_LONG, rem = shift % BITS_PER_LONG;
164 for (k = lim - off - 1; k >= 0; --k) { 164 for (k = lim - off - 1; k >= 0; --k) {
165 unsigned long upper, lower; 165 unsigned long upper, lower;
@@ -172,13 +172,8 @@ void __bitmap_shift_left(unsigned long *dst, const unsigned long *src,
172 lower = src[k - 1] >> (BITS_PER_LONG - rem); 172 lower = src[k - 1] >> (BITS_PER_LONG - rem);
173 else 173 else
174 lower = 0; 174 lower = 0;
175 upper = src[k]; 175 upper = src[k] << rem;
176 if (left && k == lim - 1)
177 upper &= (1UL << left) - 1;
178 upper <<= rem;
179 dst[k + off] = lower | upper; 176 dst[k + off] = lower | upper;
180 if (left && k + off == lim - 1)
181 dst[k + off] &= (1UL << left) - 1;
182 } 177 }
183 if (off) 178 if (off)
184 memset(dst, 0, off*sizeof(unsigned long)); 179 memset(dst, 0, off*sizeof(unsigned long));