2021-11-09 23:52:34

by Guo Zhengkui

[permalink] [raw]
Subject: [PATCH] ACPICA: fix swap.cocci warning

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

Signed-off-by: Guo Zhengkui <[email protected]>
---
drivers/acpi/acpica/nsrepair2.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 14b71b41e845..02a904ca4caf 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -8,6 +8,7 @@
*
*****************************************************************************/

+#include <linux/minmax.h>
#include <acpi/acpi.h>
#include "accommon.h"
#include "acnamesp.h"
@@ -875,7 +876,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 +892,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.20.1


2021-11-18 14:46:24

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] ACPICA: fix swap.cocci warning

On Tue, Nov 9, 2021 at 2:47 PM Guo Zhengkui <[email protected]> wrote:
>
> Fix following swap.cocci warning:
> ./drivers/acpi/acpica/nsrepair2.c:896:33-34: WARNING
> opportunity for swap()
>
> Signed-off-by: Guo Zhengkui <[email protected]>

This change needs to be submitted to the upstream ACPICA project via
https://github.com/acpica/acpica/

Thanks!

> ---
> drivers/acpi/acpica/nsrepair2.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
> index 14b71b41e845..02a904ca4caf 100644
> --- a/drivers/acpi/acpica/nsrepair2.c
> +++ b/drivers/acpi/acpica/nsrepair2.c
> @@ -8,6 +8,7 @@
> *
> *****************************************************************************/
>
> +#include <linux/minmax.h>
> #include <acpi/acpi.h>
> #include "accommon.h"
> #include "acnamesp.h"
> @@ -875,7 +876,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 +892,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.20.1
>

2021-11-19 06:31:03

by Guo Zhengkui

[permalink] [raw]
Subject: Re: [PATCH] ACPICA: fix swap.cocci warning

On 2021/11/18 22:46, Rafael J. Wysocki wrote:
> On Tue, Nov 9, 2021 at 2:47 PM Guo Zhengkui <[email protected]> wrote:
>>
>> Fix following swap.cocci warning:
>> ./drivers/acpi/acpica/nsrepair2.c:896:33-34: WARNING
>> opportunity for swap()
>>
>> Signed-off-by: Guo Zhengkui <[email protected]>
>
> This change needs to be submitted to the upstream ACPICA project via
> https://github.com/acpica/acpica/
>
> Thanks!

So it means I need to submit this patch to upstream ACPICA project, not
linux-next?

>
>> ---
>> drivers/acpi/acpica/nsrepair2.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
>> index 14b71b41e845..02a904ca4caf 100644
>> --- a/drivers/acpi/acpica/nsrepair2.c
>> +++ b/drivers/acpi/acpica/nsrepair2.c
>> @@ -8,6 +8,7 @@
>> *
>> *****************************************************************************/
>>
>> +#include <linux/minmax.h>
>> #include <acpi/acpi.h>
>> #include "accommon.h"
>> #include "acnamesp.h"
>> @@ -875,7 +876,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 +892,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.20.1
>>

2021-11-27 11:38:22

by Moore, Robert

[permalink] [raw]
Subject: RE: [PATCH] ACPICA: fix swap.cocci warning



-----Original Message-----
From: Guo Zhengkui <[email protected]>
Sent: Thursday, November 18, 2021 10:31 PM
To: Rafael J. Wysocki <[email protected]>
Cc: Moore, Robert <[email protected]>; Wysocki, Rafael J <[email protected]>; Len Brown <[email protected]>; ACPI Devel Maling List <[email protected]>; open list:ACPI COMPONENT ARCHITECTURE (ACPICA) <[email protected]>; Linux Kernel Mailing List <[email protected]>; kernel <[email protected]>
Subject: Re: [PATCH] ACPICA: fix swap.cocci warning

On 2021/11/18 22:46, Rafael J. Wysocki wrote:
> On Tue, Nov 9, 2021 at 2:47 PM Guo Zhengkui <[email protected]> wrote:
>>
>> Fix following swap.cocci warning:
>> ./drivers/acpi/acpica/nsrepair2.c:896:33-34: WARNING opportunity for
>> swap()
>>
>> Signed-off-by: Guo Zhengkui <[email protected]>
>
> This change needs to be submitted to the upstream ACPICA project via
> https://github.com/acpica/acpica/
>
> Thanks!

So it means I need to submit this patch to upstream ACPICA project, not linux-next?


The answer is yes.
Bob


>
>> ---
>> drivers/acpi/acpica/nsrepair2.c | 6 ++----
>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/acpi/acpica/nsrepair2.c
>> b/drivers/acpi/acpica/nsrepair2.c index 14b71b41e845..02a904ca4caf
>> 100644
>> --- a/drivers/acpi/acpica/nsrepair2.c
>> +++ b/drivers/acpi/acpica/nsrepair2.c
>> @@ -8,6 +8,7 @@
>> *
>>
>> *********************************************************************
>> ********/
>>
>> +#include <linux/minmax.h>
>> #include <acpi/acpi.h>
>> #include "accommon.h"
>> #include "acnamesp.h"
>> @@ -875,7 +876,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 +892,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.20.1
>>