From nobody Fri May 8 03:08:36 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62F61C433F5 for ; Thu, 12 May 2022 03:24:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344320AbiELDY5 (ORCPT ); Wed, 11 May 2022 23:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238977AbiELDYx (ORCPT ); Wed, 11 May 2022 23:24:53 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 945BF5D67C; Wed, 11 May 2022 20:24:51 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R431e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VCykjJ9_1652325870; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0VCykjJ9_1652325870) by smtp.aliyun-inc.com(127.0.0.1); Thu, 12 May 2022 11:24:49 +0800 From: Jiapeng Chong To: wellslutw@gmail.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, p.zabel@pengutronix.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] net: ethernet: Use swap() instead of open coding it Date: Thu, 12 May 2022 11:24:29 +0800 Message-Id: <20220512032429.94306-1-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Clean the following coccicheck warning: ./drivers/net/ethernet/sunplus/spl2sw_driver.c:217:27-28: WARNING opportunity for swap(). ./drivers/net/ethernet/sunplus/spl2sw_driver.c:222:27-28: WARNING opportunity for swap(). Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong --- drivers/net/ethernet/sunplus/spl2sw_driver.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/eth= ernet/sunplus/spl2sw_driver.c index 8320fa833d3e..cccf14325ba8 100644 --- a/drivers/net/ethernet/sunplus/spl2sw_driver.c +++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c @@ -204,8 +204,6 @@ static const struct net_device_ops netdev_ops =3D { =20 static void spl2sw_check_mac_vendor_id_and_convert(u8 *mac_addr) { - u8 tmp; - /* Byte order of MAC address of some samples are reversed. * Check vendor id and convert byte order if it is wrong. * OUI of Sunplus: fc:4b:bc @@ -213,19 +211,13 @@ static void spl2sw_check_mac_vendor_id_and_convert(u8= *mac_addr) if (mac_addr[5] =3D=3D 0xfc && mac_addr[4] =3D=3D 0x4b && mac_addr[3] =3D= =3D 0xbc && (mac_addr[0] !=3D 0xfc || mac_addr[1] !=3D 0x4b || mac_addr[2] !=3D 0= xbc)) { /* Swap mac_addr[0] and mac_addr[5] */ - tmp =3D mac_addr[0]; - mac_addr[0] =3D mac_addr[5]; - mac_addr[5] =3D tmp; + swap(mac_addr[0], mac_addr[5]); =20 /* Swap mac_addr[1] and mac_addr[4] */ - tmp =3D mac_addr[1]; - mac_addr[1] =3D mac_addr[4]; - mac_addr[4] =3D tmp; + swap(mac_addr[1], mac_addr[4]); =20 /* Swap mac_addr[2] and mac_addr[3] */ - tmp =3D mac_addr[2]; - mac_addr[2] =3D mac_addr[3]; - mac_addr[3] =3D tmp; + swap(mac_addr[2], mac_addr[3]); } } =20 --=20 2.20.1.7.g153144c