lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YEDZjM5kTJPgx1WU@smile.fi.intel.com>
Date:   Thu, 4 Mar 2021 14:58:52 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Bartosz Golaszewski <brgl@...ev.pl>
Cc:     Joel Becker <jlbec@...lplan.org>, Christoph Hellwig <hch@....de>,
        Shuah Khan <shuah@...nel.org>,
        Linus Walleij <linus.walleij@...aro.org>,
        Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        Kent Gibson <warthog618@...il.com>,
        Jonathan Corbet <corbet@....net>, linux-gpio@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
        Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: Re: [PATCH v2 05/12] lib: bitmap: remove the 'extern' keyword from
 function declarations

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

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

> Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
> ---
>  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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ