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: <20211213184152.GE12405@willie-the-truck>
Date:   Mon, 13 Dec 2021 18:41:52 +0000
From:   Will Deacon <will@...nel.org>
To:     davidcomponentone@...il.com
Cc:     peterz@...radead.org, mingo@...hat.com, longman@...hat.com,
        boqun.feng@...il.com, linux-kernel@...r.kernel.org,
        Yang Guang <yang.guang5@....com.cn>,
        Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH] locking/ww-mutex: use swap() to make code cleaner

On Thu, Nov 04, 2021 at 08:18:46AM +0800, davidcomponentone@...il.com wrote:
> From: Yang Guang <yang.guang5@....com.cn>
> 
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.
> 
> Signed-off-by: Yang Guang <yang.guang5@....com.cn>
> Reported-by: Zeal Robot <zealci@....com.cn>
> ---
>  kernel/locking/test-ww_mutex.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
> index 353004155d65..daad819fcd16 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)
> @@ -401,9 +401,7 @@ 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;
> +			swap(order[n], order[r]);

Looks correct to me:

Acked-by: Will Deacon <will@...nel.org>

Will

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ