Re: [PATCH v2 05/12] lib: bitmap: remove the 'extern' keyword from function declarations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 04, 2021 at 11:24:45AM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
> 
> The 'extern' keyword doesn't have any benefits in header files. Remove it.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
A few nitpicks below.

> Signed-off-by: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
> ---
>  include/linux/bitmap.h | 115 ++++++++++++++++++++---------------------
>  1 file changed, 57 insertions(+), 58 deletions(-)
> 
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> index 70a932470b2d..6939a8983026 100644
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -118,54 +118,53 @@
>   * Allocation and deallocation of bitmap.
>   * Provided in lib/bitmap.c to avoid circular dependency.
>   */
> -extern unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags);
> -extern unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags);
> -extern void bitmap_free(const unsigned long *bitmap);
> +unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags);
> +unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags);
> +void bitmap_free(const unsigned long *bitmap);
>  
>  /*
>   * lib/bitmap.c provides these functions:
>   */
>  
> -extern int __bitmap_equal(const unsigned long *bitmap1,
> -			  const unsigned long *bitmap2, unsigned int nbits);
> -extern bool __pure __bitmap_or_equal(const unsigned long *src1,
> -				     const unsigned long *src2,
> -				     const unsigned long *src3,
> -				     unsigned int nbits);
> -extern void __bitmap_complement(unsigned long *dst, const unsigned long *src,
> -			unsigned int nbits);
> -extern void __bitmap_shift_right(unsigned long *dst, const unsigned long *src,
> -				unsigned int shift, unsigned int nbits);
> -extern void __bitmap_shift_left(unsigned long *dst, const unsigned long *src,
> -				unsigned int shift, unsigned int nbits);
> -extern void bitmap_cut(unsigned long *dst, const unsigned long *src,
> -		       unsigned int first, unsigned int cut,
> -		       unsigned int nbits);
> -extern int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
> +int __bitmap_equal(const unsigned long *bitmap1,
> +		   const unsigned long *bitmap2, unsigned int nbits);

Logically better to have

int __bitmap_equal(const unsigned long *bitmap1, const unsigned long *bitmap2,
		   unsigned int nbits);

> +bool __pure __bitmap_or_equal(const unsigned long *src1,
> +			      const unsigned long *src2,
> +			      const unsigned long *src3,
> +			      unsigned int nbits);
> +void __bitmap_complement(unsigned long *dst, const unsigned long *src,
> +			 unsigned int nbits);
> +void __bitmap_shift_right(unsigned long *dst, const unsigned long *src,
> +			  unsigned int shift, unsigned int nbits);
> +void __bitmap_shift_left(unsigned long *dst, const unsigned long *src,
> +			 unsigned int shift, unsigned int nbits);
> +void bitmap_cut(unsigned long *dst, const unsigned long *src,
> +		unsigned int first, unsigned int cut, unsigned int nbits);
> +int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
> +		 const unsigned long *bitmap2, unsigned int nbits);
> +void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
> +		 const unsigned long *bitmap2, unsigned int nbits);
> +void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
> +		  const unsigned long *bitmap2, unsigned int nbits);
> +int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
> +		    const unsigned long *bitmap2, unsigned int nbits);
> +void __bitmap_replace(unsigned long *dst,
> +		      const unsigned long *old, const unsigned long *new,
> +		      const unsigned long *mask, unsigned int nbits);
> +int __bitmap_intersects(const unsigned long *bitmap1,
>  			const unsigned long *bitmap2, unsigned int nbits);
> -extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
> -			const unsigned long *bitmap2, unsigned int nbits);
> -extern void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
> -			const unsigned long *bitmap2, unsigned int nbits);
> -extern int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
> -			const unsigned long *bitmap2, unsigned int nbits);
> -extern void __bitmap_replace(unsigned long *dst,
> -			const unsigned long *old, const unsigned long *new,
> -			const unsigned long *mask, unsigned int nbits);
> -extern int __bitmap_intersects(const unsigned long *bitmap1,
> -			const unsigned long *bitmap2, unsigned int nbits);
> -extern int __bitmap_subset(const unsigned long *bitmap1,
> -			const unsigned long *bitmap2, unsigned int nbits);
> -extern int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits);
> -extern void __bitmap_set(unsigned long *map, unsigned int start, int len);
> -extern void __bitmap_clear(unsigned long *map, unsigned int start, int len);
> -
> -extern unsigned long bitmap_find_next_zero_area_off(unsigned long *map,
> -						    unsigned long size,
> -						    unsigned long start,
> -						    unsigned int nr,
> -						    unsigned long align_mask,
> -						    unsigned long align_offset);
> +int __bitmap_subset(const unsigned long *bitmap1,
> +		    const unsigned long *bitmap2, unsigned int nbits);
> +int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits);
> +void __bitmap_set(unsigned long *map, unsigned int start, int len);
> +void __bitmap_clear(unsigned long *map, unsigned int start, int len);
> +
> +unsigned long bitmap_find_next_zero_area_off(unsigned long *map,
> +					     unsigned long size,
> +					     unsigned long start,
> +					     unsigned int nr,
> +					     unsigned long align_mask,
> +					     unsigned long align_offset);
>  
>  /**
>   * bitmap_find_next_zero_area - find a contiguous aligned zero area
> @@ -190,33 +189,33 @@ bitmap_find_next_zero_area(unsigned long *map,
>  					      align_mask, 0);
>  }
>  
> -extern int bitmap_parse(const char *buf, unsigned int buflen,
> +int bitmap_parse(const char *buf, unsigned int buflen,
>  			unsigned long *dst, int nbits);

Can be

int bitmap_parse(const char *buf, unsigned int buflen, unsigned long *dst,
		 int nbits);

And I wonder why nbits here is signed.

> -extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
> +int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
>  			unsigned long *dst, int nbits);

Ditto.

> -extern int bitmap_parselist(const char *buf, unsigned long *maskp,

> +int bitmap_parselist(const char *buf, unsigned long *maskp,
>  			int nmaskbits);

Now can be one line.

> -extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen,
> +int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen,
>  			unsigned long *dst, int nbits);
> -extern void bitmap_remap(unsigned long *dst, const unsigned long *src,
> +void bitmap_remap(unsigned long *dst, const unsigned long *src,
>  		const unsigned long *old, const unsigned long *new, unsigned int nbits);
> -extern int bitmap_bitremap(int oldbit,

> +int bitmap_bitremap(int oldbit,
>  		const unsigned long *old, const unsigned long *new, int bits);

More logical

int bitmap_bitremap(int oldbit, const unsigned long *old,
		    const unsigned long *new, int bits);

Or even

int bitmap_bitremap(int oldbit, const unsigned long *old, const unsigned long *new,
		    int bits);

> -extern void bitmap_onto(unsigned long *dst, const unsigned long *orig,
> +void bitmap_onto(unsigned long *dst, const unsigned long *orig,
>  		const unsigned long *relmap, unsigned int bits);
> -extern void bitmap_fold(unsigned long *dst, const unsigned long *orig,
> +void bitmap_fold(unsigned long *dst, const unsigned long *orig,
>  		unsigned int sz, unsigned int nbits);
> -extern int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order);
> -extern void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order);
> -extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order);
> +int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order);
> +void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order);
> +int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order);
>  
>  #ifdef __BIG_ENDIAN
> -extern void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int nbits);
> +void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int nbits);
>  #else
>  #define bitmap_copy_le bitmap_copy
>  #endif
> -extern unsigned int bitmap_ord_to_pos(const unsigned long *bitmap, unsigned int ord, unsigned int nbits);
> -extern int bitmap_print_to_pagebuf(bool list, char *buf,
> +unsigned int bitmap_ord_to_pos(const unsigned long *bitmap, unsigned int ord, unsigned int nbits);
> +int bitmap_print_to_pagebuf(bool list, char *buf,
>  				   const unsigned long *maskp, int nmaskbits);
>  
>  #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
> @@ -265,9 +264,9 @@ static inline void bitmap_copy_clear_tail(unsigned long *dst,
>   * therefore conversion is not needed when copying data from/to arrays of u32.
>   */
>  #if BITS_PER_LONG == 64
> -extern void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf,
> +void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf,
>  							unsigned int nbits);

One line?

> -extern void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap,
> +void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap,
>  							unsigned int nbits);

Ditto.

>  #else
>  #define bitmap_from_arr32(bitmap, buf, nbits)			\
> -- 
> 2.29.1
> 

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux