From: Waiman Long <longman@redhat.com>
To: cgel.zte@gmail.com
Cc: mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com,
linux-kernel@vger.kernel.org,
Changcheng Deng <deng.changcheng@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] locking/test-ww_mutex: use swap()
Date: Wed, 20 Oct 2021 09:59:29 -0400 [thread overview]
Message-ID: <caa4e95c-7992-526e-83d5-db154681c57b@redhat.com> (raw)
In-Reply-To: <20211020091545.1039063-1-deng.changcheng@zte.com.cn>
On 10/20/21 5:15 AM, cgel.zte@gmail.com wrote:
> 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 | 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 353004155d65..fa021b8a9edc 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)
> @@ -400,11 +400,8 @@ 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;
> - }
> + if (r != n)
> + swap(order[n], order[r]);
> }
>
> return order;
Acked-by: Waiman Long <longman@redhat.com>
prev parent reply other threads:[~2021-10-20 14:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-20 9:15 [PATCH] locking/test-ww_mutex: use swap() cgel.zte
2021-10-20 13:59 ` Waiman Long [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=caa4e95c-7992-526e-83d5-db154681c57b@redhat.com \
--to=longman@redhat.com \
--cc=boqun.feng@gmail.com \
--cc=cgel.zte@gmail.com \
--cc=deng.changcheng@zte.com.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=will@kernel.org \
--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).