diff mbox series

[v2] net: ethernet: Use swap() instead of open coding it

Message ID 20220512060905.33744-1-jiapeng.chong@linux.alibaba.com (mailing list archive)
State Accepted
Commit a19cef450bb6b1365c3bd5c82952f95b76688143
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: ethernet: Use swap() instead of open coding it | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning CHECK: Blank lines aren't necessary after an open brace '{'
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Jiapeng Chong May 12, 2022, 6:09 a.m. UTC
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>
---
Changes in v2:
  -Delete useless comments.

 drivers/net/ethernet/sunplus/spl2sw_driver.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org May 13, 2022, 10:30 a.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 12 May 2022 14:09:05 +0800 you wrote:
> 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().
> 
> [...]

Here is the summary with links:
  - [v2] net: ethernet: Use swap() instead of open coding it
    https://git.kernel.org/netdev/net-next/c/a19cef450bb6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sunplus/spl2sw_driver.c b/drivers/net/ethernet/sunplus/spl2sw_driver.c
index 8320fa833d3e..1cb7076f946d 100644
--- a/drivers/net/ethernet/sunplus/spl2sw_driver.c
+++ b/drivers/net/ethernet/sunplus/spl2sw_driver.c
@@ -204,28 +204,16 @@  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
 	 */
 	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[1] and mac_addr[4] */
-		tmp = mac_addr[1];
-		mac_addr[1] = mac_addr[4];
-		mac_addr[4] = tmp;
-
-		/* 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[0], mac_addr[5]);
+		swap(mac_addr[1], mac_addr[4]);
+		swap(mac_addr[2], mac_addr[3]);
 	}
 }