Skip to contentSkip to conversation

x86/unwind/orc: Use swap() instead of open coding it

PATCH Applied Jiapeng Chong 2 participants 2 messages Mar 30, 2023 – May 18, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/unwind/orc: 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/x86/kernel/unwind_orc.c:235:16-17: WARNING opportunity for swap().

---
 arch/x86/kernel/unwind_orc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/unwind_orc.c +1 -4
index 3ac50b7298d1..5fbcb229f707 100644
@@ -219,7 +219,6 @@ static struct orc_entry *cur_orc_table = __start_orc_unwind;
 static void orc_sort_swap(void *_a, void *_b, int size)
 {
 	struct orc_entry *orc_a, *orc_b;
-	struct orc_entry orc_tmp;
 	int *a = _a, *b = _b, tmp;
 	int delta = _b - _a;
 
@@ -231,9 +230,7 @@ static void orc_sort_swap(void *_a, void *_b, int size)
 	/* Swap the corresponding .orc_unwind entries: */
 	orc_a = cur_orc_table + (a - cur_orc_ip_table);
 	orc_b = cur_orc_table + (b - cur_orc_ip_table);
-	orc_tmp = *orc_a;
-	*orc_a = *orc_b;
-	*orc_b = orc_tmp;
+	swap(*orc_a, *orc_b);
 }
 
 static int orc_sort_cmp(const void *_a, const void *_b)
Signature · 1 line
2.20.1.7.g153144c
merge bot Applied
#1 lore raw
The following commit has been merged into the objtool/core branch of tip:

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     95f0e3a209b0045a56a06987d85981280f523270
Gitweb:        https://git.kernel.org/tip/95f0e3a209b0045a56a06987d85981280f523270
Author:        Jiapeng Chong <[email protected]>
AuthorDate:    Thu, 30 Mar 2023 10:00:14 +08:00
Committer:     Josh Poimboeuf <[email protected]>
CommitterDate: Tue, 16 May 2023 06:06:56 -07:00

x86/unwind/orc: 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/x86/kernel/unwind_orc.c:235:16-17: WARNING opportunity for swap().

---
 arch/x86/kernel/unwind_orc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/x86/kernel/unwind_orc.c +1 -4
index 3ac50b7..5fbcb22 100644
@@ -219,7 +219,6 @@ static struct orc_entry *cur_orc_table = __start_orc_unwind;
 static void orc_sort_swap(void *_a, void *_b, int size)
 {
 	struct orc_entry *orc_a, *orc_b;
-	struct orc_entry orc_tmp;
 	int *a = _a, *b = _b, tmp;
 	int delta = _b - _a;
 
@@ -231,9 +230,7 @@ static void orc_sort_swap(void *_a, void *_b, int size)
 	/* Swap the corresponding .orc_unwind entries: */
 	orc_a = cur_orc_table + (a - cur_orc_ip_table);
 	orc_b = cur_orc_table + (b - cur_orc_ip_table);
-	orc_tmp = *orc_a;
-	*orc_a = *orc_b;
-	*orc_b = orc_tmp;
+	swap(*orc_a, *orc_b);
 }
 
 static int orc_sort_cmp(const void *_a, const void *_b)