Skip to contentSkip to conversation

ACPICA: Use swap() instead of open coding it

PATCH In review Jiapeng Chong 2 participants 2 messages Feb 2, 2024

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

PATCH 1/1 ACPICA: 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.

./drivers/acpi/acpica/nsrepair2.c:896:33-34: WARNING opportunity for swap().

---
 drivers/acpi/acpica/nsrepair2.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/acpi/acpica/nsrepair2.c +1 -4
index 1bb7b71f07f1..ccd89a82a4e6 100644
@@ -875,7 +875,6 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
 {
 	union acpi_operand_object *obj_desc1;
 	union acpi_operand_object *obj_desc2;
-	union acpi_operand_object *temp_obj;
 	u32 i;
 	u32 j;
 
@@ -892,9 +891,7 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
 			    || ((sort_direction == ACPI_SORT_DESCENDING)
 				&& (obj_desc1->integer.value <
 				    obj_desc2->integer.value))) {
-				temp_obj = elements[j - 1];
-				elements[j - 1] = elements[j];
-				elements[j] = temp_obj;
+				swap(elements[j], elements[j - 1]);
 			}
 		}
 	}
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw
Quoted 5 lines · Jiapeng Chong

Swap is a function interface that provides exchange function. To avoid code duplication, we can use swap function.

./drivers/acpi/acpica/nsrepair2.c:896:33-34: WARNING opportunity for swap().

In order to modify the ACPICA code in the Linux kernel, you need to submit a corresponding pull request to the upstream ACPICA project on GitHub. Once that pull request has been merged, please send the Linux patch with a Link: tag pointing to the upstream ACPICA pull request corresponding to it.

Thanks!

Quoted 34 lines
---
 drivers/acpi/acpica/nsrepair2.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/acpi/acpica/nsrepair2.c +1 -5
index 1bb7b71f07f1..ccd89a82a4e6 100644
@@ -875,7 +875,6 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
 {
        union acpi_operand_object *obj_desc1;
        union acpi_operand_object *obj_desc2;
-       union acpi_operand_object *temp_obj;
        u32 i;
        u32 j;
 
@@ -892,9 +891,7 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
                            || ((sort_direction == ACPI_SORT_DESCENDING)
                                && (obj_desc1->integer.value <
                                    obj_desc2->integer.value))) {
-                               temp_obj = elements[j - 1];
-                               elements[j - 1] = elements[j];
-                               elements[j] = temp_obj;
+                               swap(elements[j], elements[j - 1]);
                        }
                }
        }
--

2.20.1.7.g153144c