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: <c9d2c56c-097d-43f8-ac87-54b1dffbc863@redhat.com>
Date: Fri, 28 Jun 2024 15:33:33 -0400
From: Waiman Long <longman@...hat.com>
To: Thorsten Blum <thorsten.blum@...lux.com>, peterz@...radead.org,
 mingo@...hat.com, will@...nel.org, boqun.feng@...il.com
Cc: linux-kernel@...r.kernel.org
Subject: Re: [RESEND PATCH] locking/ww_mutex/test: Use swap() macro

On 6/28/24 15:29, Thorsten Blum wrote:
> Fixes the following Coccinelle/coccicheck warning reported by
> swap.cocci:
>
>    WARNING opportunity for swap()
>
> Compile-tested only.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> ---
>   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 78719e1ef1b1..252bef786aef 100644
> --- a/kernel/locking/test-ww_mutex.c
> +++ b/kernel/locking/test-ww_mutex.c
> @@ -402,7 +402,7 @@ static inline u32 prandom_u32_below(u32 ceil)
>   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)
> @@ -413,11 +413,8 @@ static int *get_random_order(int count)
>   
>   	for (n = count - 1; n > 1; n--) {
>   		r = prandom_u32_below(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