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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210825080026.GM3@paasikivi.fi.intel.com>
Date:   Wed, 25 Aug 2021 11:00:26 +0300
From:   Sakari Ailus <sakari.ailus@...ux.intel.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
        linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
        Yong Zhi <yong.zhi@...el.com>,
        Bingbu Cao <bingbu.cao@...el.com>,
        Dan Scally <djrscally@...il.com>,
        Tianshu Qiu <tian.shu.qiu@...el.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>
Subject: Re: [PATCH v1 1/3] lib/sort: Split out choose_swap_func() local
 helper

Hi Andy,

Thanks for the set.

On Tue, Aug 24, 2021 at 04:33:49PM +0300, Andy Shevchenko wrote:
> In some new code we may need the same functionality as provided by
> newly introduced choose_swap_func() helper.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
>  lib/sort.c | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/sort.c b/lib/sort.c
> index aa18153864d2..d9b2f5b73620 100644
> --- a/lib/sort.c
> +++ b/lib/sort.c
> @@ -151,6 +151,18 @@ static int do_cmp(const void *a, const void *b, cmp_r_func_t cmp, const void *pr
>  	return cmp(a, b, priv);
>  }
>  
> +static swap_func_t choose_swap_func(swap_func_t swap_func, void *base, size_t size)

Over 80, please wrap.

> +{
> +	if (swap_func)
> +		return swap_func;
> +
> +	if (is_aligned(base, size, 8))
> +		return SWAP_WORDS_64;
> +	if (is_aligned(base, size, 4))
> +		return SWAP_WORDS_32;

A newline here would be nice.

> +	return SWAP_BYTES;
> +}
> +
>  /**
>   * parent - given the offset of the child, find the offset of the parent.
>   * @i: the offset of the heap element whose parent is sought.  Non-zero.
> @@ -208,14 +220,7 @@ void sort_r(void *base, size_t num, size_t size,
>  	if (!a)		/* num < 2 || size == 0 */
>  		return;
>  
> -	if (!swap_func) {
> -		if (is_aligned(base, size, 8))
> -			swap_func = SWAP_WORDS_64;
> -		else if (is_aligned(base, size, 4))
> -			swap_func = SWAP_WORDS_32;
> -		else
> -			swap_func = SWAP_BYTES;
> -	}
> +	swap_func = choose_swap_func(swap_func, base, size);
>  
>  	/*
>  	 * Loop invariants:

-- 
Kind regards,

Sakari Ailus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ