linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: davidcomponentone@gmail.com
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio <linux-iio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Yang Guang <yang.guang5@zte.com.cn>,
	Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] tools: iio: use swap() to make code cleaner
Date: Thu, 4 Nov 2021 12:33:19 +0200	[thread overview]
Message-ID: <CAHp75VedwDcBoz=dOGf_-7aOHC1mdvT8+hyvyK+hbK-5soJoYw@mail.gmail.com> (raw)
In-Reply-To: <20211104062032.1505899-1-yang.guang5@zte.com.cn>

On Thu, Nov 4, 2021 at 8:21 AM <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.

Same as per other patches. Don't be a dump addon to the robot, think
about the code a little bit more.

>  void bsort_channel_array_by_index(struct iio_channel_info *ci_array, int cnt)
>  {
> -       struct iio_channel_info temp;
>         int x, y;
>
>         for (x = 0; x < cnt; x++)
>                 for (y = 0; y < (cnt - 1); y++)
>                         if (ci_array[y].index > ci_array[y + 1].index) {
> -                               temp = ci_array[y + 1];
> -                               ci_array[y + 1] = ci_array[y];
> -                               ci_array[y] = temp;
> +                               swap(ci_array[y + 1], ci_array[y]);
>                         }

Name of the function suggests it's a sort, we have the sort_r() API,
use it instead.

>  }

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2021-11-04 10:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-04  6:20 [PATCH] tools: iio: use swap() to make code cleaner davidcomponentone
2021-11-04 10:33 ` Andy Shevchenko [this message]
2021-11-04 10:36   ` Andy Shevchenko
2021-11-14 16:05     ` Jonathan Cameron

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='CAHp75VedwDcBoz=dOGf_-7aOHC1mdvT8+hyvyK+hbK-5soJoYw@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=davidcomponentone@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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).