linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] locking/ww-mutex: use swap() to make code cleaner
@ 2021-11-04  0:18 davidcomponentone
  2021-12-13 18:41 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: davidcomponentone @ 2021-11-04  0:18 UTC (permalink / raw)
  To: peterz
  Cc: davidcomponentone, mingo, will, longman, boqun.feng,
	linux-kernel, Yang Guang, Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
Reported-by: Zeal Robot <zealci@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.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-13 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04  0:18 [PATCH] locking/ww-mutex: use swap() to make code cleaner davidcomponentone
2021-12-13 18:41 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).