[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20211028120220.GA1907@pc638.lan>
Date: Thu, 28 Oct 2021 14:02:20 +0200
From: Uladzislau Rezki <urezki@...il.com>
To: cgel.zte@...il.com
Cc: akpm@...ux-foundation.org, urezki@...il.com,
deng.changcheng@....com.cn, linux-kernel@...r.kernel.org,
Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH] lib/test_vmalloc.c: use swap() to make code cleaner
On Thu, Oct 28, 2021 at 11:14:43AM +0000, 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>
> ---
> lib/test_vmalloc.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
> index e14993bc84d2..cf41fd6df42a 100644
> --- a/lib/test_vmalloc.c
> +++ b/lib/test_vmalloc.c
> @@ -393,7 +393,7 @@ static struct test_driver {
> static void shuffle_array(int *arr, int n)
> {
> unsigned int rnd;
> - int i, j, x;
> + int i, j;
>
> for (i = n - 1; i > 0; i--) {
> get_random_bytes(&rnd, sizeof(rnd));
> @@ -402,9 +402,7 @@ static void shuffle_array(int *arr, int n)
> j = rnd % i;
>
> /* Swap indexes. */
> - x = arr[i];
> - arr[i] = arr[j];
> - arr[j] = x;
> + swap(arr[i], arr[j]);
> }
> }
>
> --
> 2.25.1
Makes sense to me: Reviewed-by: Uladzislau Rezki (Sony) <urezki@...il.com>
--
Vlad Rezki
Powered by blists - more mailing lists