s390/vmem: Use swap() instead of open coding it
PATCH 1/1 s390/vmem: Use swap() instead of open coding it
Swap is a function interface that provides exchange function. To avoid code duplication, we can use swap function.
./arch/s390/mm/vmem.c:680:10-11: WARNING opportunity for swap().
--- arch/s390/mm/vmem.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/s390/mm/vmem.c +1 -4
@@ -674,11 +674,8 @@ static void __init memblock_region_swap(void *a, void *b, int size) {struct memblock_region *r1 = a;struct memblock_region *r2 = b; -struct memblock_region swap; - swap = *r1; - *r1 = *r2; - *r2 = swap; +swap (*r1, *r2); }/*
Signature · 1 line
2.20.1.7.g153144c
Heiko Carstens
maintainerQuoted 17 lines · Jiapeng Chong
Swap is a function interface that provides exchange function. To avoid code duplication, we can use swap function.
./arch/s390/mm/vmem.c:680:10-11: WARNING opportunity for
swap().Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>--- arch/s390/mm/vmem.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)arch/s390/mm/vmem.c +0
-0
arch/s390/mm/vmem.c static void __init memblock_region_swap(void *a, void *b, int size) · line 679
Quoted 10 lines
arch/s390/mm/vmem.c +1
-4@@ -674,11 +674,8 @@ static void __init memblock_region_swap(void *a, void *b, int size) {struct memblock_region *r1 = a;struct memblock_region *r2 = b; -struct memblock_region swap; - swap = *r1; - *r1 = *r2; - *r2 = swap; +swap (*r1, *r2); }
Let's remove r1, and r2 as well. I applied the below:
From ff3ebe76f3b9481e6553bc2f05b52a266cd2e4a5 Mon Sep 17 00:00:00 2001
From: Jiapeng Chong <[email protected]>
Date: Tue, 17 Jan 2023 14:02:23 +0800
Subject: [PATCH] s390/vmem: use swap() instead of open coding it
Swap is a function interface that provides exchange function. To avoid code duplication, we can use swap function.
./arch/s390/mm/vmem.c:680:10-11: WARNING opportunity for swap().
--- arch/s390/mm/vmem.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
arch/s390/mm/vmem.c +1 -7
@@ -672,13 +672,7 @@ static int __init memblock_region_cmp(const void *a, const void *b)static void __init memblock_region_swap (void *a,void *b,int size) { -struct memblock_region *r1 = a; -struct memblock_region *r2 = b; -struct memblock_region swap; - - swap = *r1; - *r1 = *r2; - *r2 = swap; +swap (*(struct memblock_region *)a, *(struct memblock_region *)b); }/*
Signature · 1 line
2.34.1