* [RESEND PATCH] locking/ww_mutex/test: Use swap() macro
@ 2024-07-31 13:58 Thorsten Blum
2024-10-28 17:38 ` Boqun Feng
0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2024-07-31 13:58 UTC (permalink / raw)
To: peterz, mingo, will, longman, boqun.feng; +Cc: linux-kernel, Thorsten Blum
Fixes the following Coccinelle/coccicheck warning reported by
swap.cocci:
WARNING opportunity for swap()
Compile-tested only.
Acked-by: Waiman Long <longman@redhat.com>
Signed-off-by: Thorsten Blum <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 78719e1ef1b1..252bef786aef 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -402,7 +402,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)
@@ -413,11 +413,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;
--
2.45.2
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [RESEND PATCH] locking/ww_mutex/test: Use swap() macro
2024-07-31 13:58 [RESEND PATCH] locking/ww_mutex/test: Use swap() macro Thorsten Blum
@ 2024-10-28 17:38 ` Boqun Feng
0 siblings, 0 replies; 4+ messages in thread
From: Boqun Feng @ 2024-10-28 17:38 UTC (permalink / raw)
To: Thorsten Blum; +Cc: peterz, mingo, will, longman, linux-kernel, Jiapeng Chong
On Wed, Jul 31, 2024 at 03:58:51PM +0200, Thorsten Blum wrote:
> Fixes the following Coccinelle/coccicheck warning reported by
> swap.cocci:
>
> WARNING opportunity for swap()
>
> Compile-tested only.
>
> Acked-by: Waiman Long <longman@redhat.com>
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Queued into lockdep-for-tip, with additional tags from:
https://lore.kernel.org/r/20241025081455.55089-1-jiapeng.chong@linux.alibaba.com
Thanks!
Regards,
Boqun
> ---
> 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 78719e1ef1b1..252bef786aef 100644
> --- a/kernel/locking/test-ww_mutex.c
> +++ b/kernel/locking/test-ww_mutex.c
> @@ -402,7 +402,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)
> @@ -413,11 +413,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;
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RESEND PATCH] locking/ww_mutex/test: Use swap() macro
@ 2024-06-28 19:29 Thorsten Blum
2024-06-28 19:33 ` Waiman Long
0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2024-06-28 19:29 UTC (permalink / raw)
To: peterz, mingo, will, longman, boqun.feng; +Cc: linux-kernel, Thorsten Blum
Fixes the following Coccinelle/coccicheck warning reported by
swap.cocci:
WARNING opportunity for swap()
Compile-tested only.
Signed-off-by: Thorsten Blum <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 78719e1ef1b1..252bef786aef 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -402,7 +402,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)
@@ -413,11 +413,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;
--
2.45.2
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [RESEND PATCH] locking/ww_mutex/test: Use swap() macro
2024-06-28 19:29 Thorsten Blum
@ 2024-06-28 19:33 ` Waiman Long
0 siblings, 0 replies; 4+ messages in thread
From: Waiman Long @ 2024-06-28 19:33 UTC (permalink / raw)
To: Thorsten Blum, peterz, mingo, will, boqun.feng; +Cc: linux-kernel
On 6/28/24 15:29, Thorsten Blum wrote:
> Fixes the following Coccinelle/coccicheck warning reported by
> swap.cocci:
>
> WARNING opportunity for swap()
>
> Compile-tested only.
>
> Signed-off-by: Thorsten Blum <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 78719e1ef1b1..252bef786aef 100644
> --- a/kernel/locking/test-ww_mutex.c
> +++ b/kernel/locking/test-ww_mutex.c
> @@ -402,7 +402,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)
> @@ -413,11 +413,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;
Acked-by: Waiman Long <longman@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-28 17:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-31 13:58 [RESEND PATCH] locking/ww_mutex/test: Use swap() macro Thorsten Blum
2024-10-28 17:38 ` Boqun Feng
-- strict thread matches above, loose matches on Subject: below --
2024-06-28 19:29 Thorsten Blum
2024-06-28 19:33 ` Waiman Long
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®