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>] [day] [month] [year] [list]
Message-ID: <173506642497.399.671600444798182994.tip-bot2@tip-bot2>
Date: Tue, 24 Dec 2024 18:53:44 -0000
From: "tip-bot2 for Thorsten Blum" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Abaci Robot <abaci@...ux.alibaba.com>,
 Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>,
 Waiman Long <longman@...hat.com>, Thorsten Blum <thorsten.blum@...lux.com>,
 Boqun Feng <boqun.feng@...il.com>, x86@...nel.org,
 linux-kernel@...r.kernel.org
Subject: [tip: locking/core] locking/ww_mutex/test: Use swap() macro

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     0d3547df6934b8f9600630322799a2a76b4567d8
Gitweb:        https://git.kernel.org/tip/0d3547df6934b8f9600630322799a2a76b4567d8
Author:        Thorsten Blum <thorsten.blum@...lux.com>
AuthorDate:    Wed, 31 Jul 2024 15:58:51 +02:00
Committer:     Boqun Feng <boqun.feng@...il.com>
CommitterDate: Sun, 15 Dec 2024 11:49:35 -08:00

locking/ww_mutex/test: Use swap() macro

Fixes the following Coccinelle/coccicheck warning reported by
swap.cocci:

  WARNING opportunity for swap()

Compile-tested only.

[Boqun: Add the report tags from Jiapeng and Abaci Robot [1].]

Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
Reported-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=11531
Link: https://lore.kernel.org/r/20241025081455.55089-1-jiapeng.chong@linux.alibaba.com [1]
Acked-by: Waiman Long <longman@...hat.com>
Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
Signed-off-by: Boqun Feng <boqun.feng@...il.com>
Link: https://lore.kernel.org/r/20240731135850.81018-2-thorsten.blum@toblux.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 5d58b2c..bcb1b9f 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -404,7 +404,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)
@@ -415,11 +415,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;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ