lkml.org 
[lkml]   [2021]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] locking/ww-mutex: use swap()
Date
From: Changcheng Deng <deng.changcheng@zte.com.cn>

Use swap() in order to make code cleaner. Issue found by coccinelle.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.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]);
}
}

--
2.25.1
\
 
 \ /
  Last update: 2021-10-19 05:24    [W:0.027 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site