lkml.org 
[lkml]   [2021]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] tools: iio: use swap() to make code cleaner
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

\
 
 \ /
  Last update: 2021-11-04 11:35    [W:0.040 / U:0.596 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site