Commit ccf7a6d4 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Torvalds

lib/bitmap.c: drop unnecessary 0 check for u32 array operations

nbits == 0 is safe to be supplied to the function body, so remove
unnecessary checks in bitmap_to_arr32() and bitmap_from_arr32().

Link: http://lkml.kernel.org/r/20180531131914.44352-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarYury Norov <ynorov@caviumnetworks.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0fbd75fd
...@@ -1152,14 +1152,10 @@ EXPORT_SYMBOL(bitmap_free); ...@@ -1152,14 +1152,10 @@ EXPORT_SYMBOL(bitmap_free);
* @buf: array of u32 (in host byte order), the source bitmap * @buf: array of u32 (in host byte order), the source bitmap
* @nbits: number of bits in @bitmap * @nbits: number of bits in @bitmap
*/ */
void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned int nbits)
unsigned int nbits)
{ {
unsigned int i, halfwords; unsigned int i, halfwords;
if (!nbits)
return;
halfwords = DIV_ROUND_UP(nbits, 32); halfwords = DIV_ROUND_UP(nbits, 32);
for (i = 0; i < halfwords; i++) { for (i = 0; i < halfwords; i++) {
bitmap[i/2] = (unsigned long) buf[i]; bitmap[i/2] = (unsigned long) buf[i];
...@@ -1183,9 +1179,6 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits) ...@@ -1183,9 +1179,6 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits)
{ {
unsigned int i, halfwords; unsigned int i, halfwords;
if (!nbits)
return;
halfwords = DIV_ROUND_UP(nbits, 32); halfwords = DIV_ROUND_UP(nbits, 32);
for (i = 0; i < halfwords; i++) { for (i = 0; i < halfwords; i++) {
buf[i] = (u32) (bitmap[i/2] & UINT_MAX); buf[i] = (u32) (bitmap[i/2] & UINT_MAX);
......
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