From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E42B5C433F5 for ; Thu, 4 Nov 2021 10:34:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C24766120E for ; Thu, 4 Nov 2021 10:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231166AbhKDKgw (ORCPT ); Thu, 4 Nov 2021 06:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230494AbhKDKgr (ORCPT ); Thu, 4 Nov 2021 06:36:47 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AC15C061714; Thu, 4 Nov 2021 03:34:09 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id o8so19588611edc.3; Thu, 04 Nov 2021 03:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0WAWxekwAKEg4Lw/OjAqf1ORTwsGFlNLlSZUUC7fMDU=; b=hCHscLzPNc3U9u1IlLXalt2HQLye2L9/UL21RPk57m1rLafutXaPgR7DxaMoqu2uoR tu9aIVrpPZO7rJXebgeSeadjTfsZUlrdD+Z9RSMTs/5IJmbDu00JzMbL+znhP+4CNue8 3WDTwETrZP1MBhGwvC22IzR3KDRar+7hvFxZHGsOeBvXlRQMUNyEqy8bvFjEgIzOjX11 mZ32WzJXSpkOKVk9hdcV0svDEA2cUfJPAsJgPE88rL0UQXr/+d8Ud9pi8U8k/ebcoNfa NcT6lDHc6T3L1894F48C2Y3KrhfGpB2QWp7fcayeolUACgOic15eoIqqyceOYgTgnkq0 lELQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0WAWxekwAKEg4Lw/OjAqf1ORTwsGFlNLlSZUUC7fMDU=; b=lign4qNe06yY+REwhfq/+zkkqcPAfoTQ0JLkxluEa1B8xl469vkGAPJXUzfMCE4elN 4Ac3DvTZxDMC6m7mGslNNi8aQ536mVEQyH4J9bB2XHgwiCRKtDwNSdVKRGyF8pDngAec qFREawbq6QjGIb4M0FXVI2tjI9Ql3Mdbdk3WJeHxujkGjwCYRLdRUIBlhTP0LnE73+T5 NnqidKFwybzGCHhFAoWX9rlg7Bb58yk161qNGIn83oSsvmnC6EtHqo6ANRow7zxfTwVi 2OIpipEDV/cioz4HuZsxzxrsGjGGSok+TBkJAnkFbUjwsMr1Gi+mk+3bGAXicMZJ58wv SFsA== X-Gm-Message-State: AOAM533EpnMBaYpo0HrKIXbzFcFduXbyC7aDO19mrpPA0+fNEFqYRLGU G4mSkq8MvIW+Zmfg0EifmH1EdZ3eG3KcUJM+zhoRvuoQqVcoSQ== X-Google-Smtp-Source: ABdhPJy0yy674rnN0APF1AkrSGhwyl+rpns1tjiL5+G/9PtnnwkRZZgZu6C1cJl9uKCMdSLl/EGpHXKIXASbPoP30qo= X-Received: by 2002:a17:906:6a0a:: with SMTP id qw10mr35321924ejc.141.1636022047528; Thu, 04 Nov 2021 03:34:07 -0700 (PDT) MIME-Version: 1.0 References: <20211104062032.1505899-1-yang.guang5@zte.com.cn> In-Reply-To: <20211104062032.1505899-1-yang.guang5@zte.com.cn> From: Andy Shevchenko Date: Thu, 4 Nov 2021 12:33:19 +0200 Message-ID: Subject: Re: [PATCH] tools: iio: use swap() to make code cleaner To: davidcomponentone@gmail.com Cc: Jonathan Cameron , Lars-Peter Clausen , linux-iio , Linux Kernel Mailing List , Yang Guang , Zeal Robot Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 4, 2021 at 8:21 AM wrote: > > From: Yang Guang > > 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