bitmap: Drop unnecessary 0 check for u32 array operations
Subsystems (2)
PATCH 1/1 bitmap: Drop unnecessary 0 check for u32 array operations
The nbits == 0 is safe to be supplied to the function body, so, remove unnecessary checks in bitmap_to_arr32() and bitmap_from_arr32().
--- lib/bitmap.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
lib/bitmap.c +1 -8
@@ -1132,14 +1132,10 @@ EXPORT_SYMBOL(bitmap_copy_le);* @buf: array of u32 (in host byte order), the source bitmap * @nbits: number of bits in @bitmap */ -void bitmap_from_arr32 (unsigned long *bitmap,const u32 *buf, -unsigned int nbits) +void bitmap_from_arr32 (unsigned long *bitmap,const u32 *buf,unsigned int nbits) {unsigned int i, halfwords; -if (!nbits) -return ; - halfwords =DIV_ROUND_UP (nbits,32 );for (i =0 ; i < halfwords; i++) { bitmap[i/2 ] = (unsigned long ) buf[i];
@@ -1163,9 +1159,6 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits) {unsigned int i, halfwords; -if (!nbits) -return ; - halfwords =DIV_ROUND_UP (nbits,32 );for (i =0 ; i < halfwords; i++) { buf[i] = (u32) (bitmap[i/2 ] &UINT_MAX );
Signature · 1 line
2.17.0
Quoted 4 lines · Andy Shevchenko
The nbits == 0 is safe to be supplied to the function body, so, remove unnecessary checks in
bitmap_to_arr32()andbitmap_from_arr32().Signed-off-by Andy Shevchenko <[email protected]>
Indeed. Thanks for the catch.
Quoted 9 lines
--- lib/bitmap.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)lib/bitmap.c +0
-0
lib/bitmap.c EXPORT_SYMBOL(bitmap_copy_le); · line 1135
Quoted 6 lines
lib/bitmap.c +1
-2@@ -1132,14 +1132,10 @@ EXPORT_SYMBOL(bitmap_copy_le);* @buf: array of u32 (in host byte order), the source bitmap * @nbits: number of bits in @bitmap */ -void bitmap_from_arr32 (unsigned long *bitmap,const u32 *buf, -unsigned int nbits) +void bitmap_from_arr32 (unsigned long *bitmap,const u32 *buf,unsigned int nbits)
This line is 81 characters length, and it will trigger checkpatch warning. (But I'm OK with it.)
Quoted 21 lines
lib/bitmap.c +0
-6{unsigned int i, halfwords; -if (!nbits) -return ; - halfwords =DIV_ROUND_UP (nbits,32 );for (i =0 ; i < halfwords; i++) { bitmap[i/2 ] = (unsigned long ) buf[i];@@ -1163,9 +1159,6 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits) {unsigned int i, halfwords; -if (!nbits) -return ; - halfwords =DIV_ROUND_UP (nbits,32 );for (i =0 ; i < halfwords; i++) { buf[i] = (u32) (bitmap[i/2 ] &UINT_MAX );Signature · 1 line
2.17.0
Quoted 8 lines · Yury Norov
Quoted 4 lines · Andy Shevchenko
The nbits == 0 is safe to be supplied to the function body, so, remove unnecessary checks in
bitmap_to_arr32()andbitmap_from_arr32().+void
bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, unsigned int nbits)This line is 81 characters length, and it will trigger checkpatch warning. (But I'm OK with it.)
I really don't care about ) at the end potentially not visible on the screen (who is using nice old hardware terminals? :-) ).
Quoted 1 line
Acked-by Yury Norov <[email protected]>
Thanks.
Signature · 2 lines
With Best Regards, Andy Shevchenko