]> Git Repo - linux.git/commitdiff
lib/test_vmalloc.c: use swap() to make code cleaner
authorChangcheng Deng <[email protected]>
Fri, 5 Nov 2021 20:39:56 +0000 (13:39 -0700)
committerLinus Torvalds <[email protected]>
Sat, 6 Nov 2021 20:30:37 +0000 (13:30 -0700)
Use swap() in order to make code cleaner.  Issue found by coccinelle.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Changcheng Deng <[email protected]>
Reported-by: Zeal Robot <[email protected]>
Reviewed-by: Uladzislau Rezki (Sony) <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
lib/test_vmalloc.c

index e14993bc84d2d91c6064a0c9ff58fef839457ea2..cf41fd6df42a08563175d558df645fff377e2e10 100644 (file)
@@ -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]);
        }
 }
 
This page took 0.057685 seconds and 4 git commands to generate.