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] [day] [month] [year] [list]
Message-ID: <caa4e95c-7992-526e-83d5-db154681c57b@redhat.com>
Date:   Wed, 20 Oct 2021 09:59:29 -0400
From:   Waiman Long <longman@...hat.com>
To:     cgel.zte@...il.com
Cc:     mingo@...hat.com, will@...nel.org, boqun.feng@...il.com,
        linux-kernel@...r.kernel.org,
        Changcheng Deng <deng.changcheng@....com.cn>,
        Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH] locking/test-ww_mutex: use swap()

On 10/20/21 5:15 AM, cgel.zte@...il.com wrote:
> From: Changcheng Deng <deng.changcheng@....com.cn>
>
> Use swap() in order to make code cleaner. Issue found by coccinelle.
>
> Reported-by: Zeal Robot <zealci@....com.cn>
> Signed-off-by: Changcheng Deng <deng.changcheng@....com.cn>
> ---
>   kernel/locking/test-ww_mutex.c | 9 +++------
>   1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
> index 353004155d65..fa021b8a9edc 100644
> --- a/kernel/locking/test-ww_mutex.c
> +++ b/kernel/locking/test-ww_mutex.c
> @@ -389,7 +389,7 @@ struct stress {
>   static int *get_random_order(int count)
>   {
>   	int *order;
> -	int n, r, tmp;
> +	int n, r;
>   
>   	order = kmalloc_array(count, sizeof(*order), GFP_KERNEL);
>   	if (!order)
> @@ -400,11 +400,8 @@ static int *get_random_order(int count)
>   
>   	for (n = count - 1; n > 1; n--) {
>   		r = get_random_int() % (n + 1);
> -		if (r != n) {
> -			tmp = order[n];
> -			order[n] = order[r];
> -			order[r] = tmp;
> -		}
> +		if (r != n)
> +			swap(order[n], order[r]);
>   	}
>   
>   	return order;

Acked-by: Waiman Long <longman@...hat.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ