2022-02-15 10:50:49

by David Yang

[permalink] [raw]
Subject: [PATCH] ACPICA: use swap() to make code cleaner

From: Yang Guang <[email protected]>

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Yang Guang <[email protected]>
Signed-off-by: David Yang <[email protected]>
---
drivers/acpi/acpica/nsrepair2.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 14b71b41e845..ac6a5397660f 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -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 - 1], elements[j]);
}
}
}
--
2.30.2


2022-02-22 05:38:02

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] ACPICA: use swap() to make code cleaner

On Tue, Feb 15, 2022 at 1:52 AM <[email protected]> wrote:
>
> From: Yang Guang <[email protected]>
>
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Yang Guang <[email protected]>
> Signed-off-by: David Yang <[email protected]>
> ---
> drivers/acpi/acpica/nsrepair2.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
> index 14b71b41e845..ac6a5397660f 100644
> --- a/drivers/acpi/acpica/nsrepair2.c
> +++ b/drivers/acpi/acpica/nsrepair2.c
> @@ -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 - 1], elements[j]);
> }
> }
> }
> --

This is an ACPICA change that should be routed through the upstream
project at https://github.com/acpica/acpica, but there is no
counterpart of swap() in the upstream code base.