Skip to content

Commit

Permalink
lib: bitmap: remove redundant code from __bitmap_shift_right
Browse files Browse the repository at this point in the history
If the condition k==lim-1 is true, we must have off == 0 (otherwise, k
could never become that big).  But in that case we have upper == 0 and
hence dst[k] == (src[k] & mask) >> rem.  Since mask consists of a
consecutive range of bits starting from the LSB, anding dst[k] with mask
is a no-op.

Signed-off-by: Rasmus Villemoes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Villemoes authored and torvalds committed Feb 14, 2015
1 parent 9d8a6b2 commit 97fb8e9
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ void __bitmap_shift_right(unsigned long *dst, const unsigned long *src,
lower &= mask;
lower >>= rem;
dst[k] = lower | upper;
if (left && k == lim - 1)
dst[k] &= mask;
}
if (off)
memset(&dst[lim - off], 0, off*sizeof(unsigned long));
Expand Down

0 comments on commit 97fb8e9

Please sign in to comment.