All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>, 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,
	Abaci Robot <abaci@linux.alibaba.com>
Subject: Re: [PATCH] net: ethernet: Use swap() instead of open coding it
Date: Thu, 12 May 2022 07:07:29 +0200	[thread overview]
Message-ID: <a7d8fa72-906d-00b8-b1a8-1bbd960eae2a@wanadoo.fr> (raw)
In-Reply-To: <20220512032429.94306-1-jiapeng.chong@linux.alibaba.com>

Le 12/05/2022 à 05:24, Jiapeng Chong a écrit :
> 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 <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>   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/ethernet/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 = {
>   
>   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] == 0xfc && mac_addr[4] == 0x4b && mac_addr[3] == 0xbc &&
>   	    (mac_addr[0] != 0xfc || mac_addr[1] != 0x4b || mac_addr[2] != 0xbc)) {
>   		/* Swap mac_addr[0] and mac_addr[5] */
> -		tmp = mac_addr[0];
> -		mac_addr[0] = mac_addr[5];
> -		mac_addr[5] = tmp;
> +		swap(mac_addr[0], mac_addr[5]);

Hi,

nitpicking: the comment above the swap is now somehow useless, the code 
being clear by itself

CJ

>   
>   		/* Swap mac_addr[1] and mac_addr[4] */
> -		tmp = mac_addr[1];
> -		mac_addr[1] = mac_addr[4];
> -		mac_addr[4] = tmp;
> +		swap(mac_addr[1], mac_addr[4]);
>   
>   		/* Swap mac_addr[2] and mac_addr[3] */
> -		tmp = mac_addr[2];
> -		mac_addr[2] = mac_addr[3];
> -		mac_addr[3] = tmp;
> +		swap(mac_addr[2], mac_addr[3]);
>   	}
>   }
>   


      reply	other threads:[~2022-05-12  5:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12  3:24 [PATCH] net: ethernet: Use swap() instead of open coding it Jiapeng Chong
2022-05-12  5:07 ` Christophe JAILLET [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=a7d8fa72-906d-00b8-b1a8-1bbd960eae2a@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=abaci@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=wellslutw@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.