From: Will Deacon <will@kernel.org>
To: davidcomponentone@gmail.com
Cc: peterz@infradead.org, mingo@redhat.com, longman@redhat.com,
boqun.feng@gmail.com, linux-kernel@vger.kernel.org,
Yang Guang <yang.guang5@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] locking/ww-mutex: use swap() to make code cleaner
Date: Mon, 13 Dec 2021 18:41:52 +0000 [thread overview]
Message-ID: <20211213184152.GE12405@willie-the-truck> (raw)
In-Reply-To: <20211104001847.694982-1-yang.guang5@zte.com.cn>
On Thu, Nov 04, 2021 at 08:18:46AM +0800, davidcomponentone@gmail.com wrote:
> 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]);
Looks correct to me:
Acked-by: Will Deacon <will@kernel.org>
Will
prev parent reply other threads:[~2021-12-13 18:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 0:18 [PATCH] locking/ww-mutex: use swap() to make code cleaner davidcomponentone
2021-12-13 18:41 ` Will Deacon [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211213184152.GE12405@willie-the-truck \
--to=will@kernel.org \
--cc=boqun.feng@gmail.com \
--cc=davidcomponentone@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yang.guang5@zte.com.cn \
--cc=zealci@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).