linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI: processor idle: fix swap.cocci warning
@ 2021-11-09  7:50 Guo Zhengkui
  2021-11-24 16:48 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Guo Zhengkui @ 2021-11-09  7:50 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel
  Cc: kernel, Guo Zhengkui

Fix following coccicheck warning:
./drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c:914:40-41:
WARNING opportunity for swap().

swap() was used instead of the tmp variable to swap values.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
---
 drivers/acpi/processor_idle.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 76ef1bcc8848..4b906bb527e8 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -20,6 +20,7 @@
 #include <linux/tick.h>
 #include <linux/cpuidle.h>
 #include <linux/cpu.h>
+#include <linux/minmax.h>
 #include <acpi/processor.h>
 
 /*
@@ -400,13 +401,10 @@ static int acpi_cst_latency_cmp(const void *a, const void *b)
 static void acpi_cst_latency_swap(void *a, void *b, int n)
 {
 	struct acpi_processor_cx *x = a, *y = b;
-	u32 tmp;
 
 	if (!(x->valid && y->valid))
 		return;
-	tmp = x->latency;
-	x->latency = y->latency;
-	y->latency = tmp;
+	swap(x->latency, y->latency);
 }
 
 static int acpi_processor_power_verify(struct acpi_processor *pr)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI: processor idle: fix swap.cocci warning
  2021-11-09  7:50 [PATCH] ACPI: processor idle: fix swap.cocci warning Guo Zhengkui
@ 2021-11-24 16:48 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2021-11-24 16:48 UTC (permalink / raw)
  To: Guo Zhengkui
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
	Linux Kernel Mailing List, kernel

On Tue, Nov 9, 2021 at 8:51 AM Guo Zhengkui <guozhengkui@vivo.com> wrote:
>
> Fix following coccicheck warning:
> ./drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c:914:40-41:
> WARNING opportunity for swap().
>
> swap() was used instead of the tmp variable to swap values.
>
> Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
> ---
>  drivers/acpi/processor_idle.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
> index 76ef1bcc8848..4b906bb527e8 100644
> --- a/drivers/acpi/processor_idle.c
> +++ b/drivers/acpi/processor_idle.c
> @@ -20,6 +20,7 @@
>  #include <linux/tick.h>
>  #include <linux/cpuidle.h>
>  #include <linux/cpu.h>
> +#include <linux/minmax.h>
>  #include <acpi/processor.h>
>
>  /*
> @@ -400,13 +401,10 @@ static int acpi_cst_latency_cmp(const void *a, const void *b)
>  static void acpi_cst_latency_swap(void *a, void *b, int n)
>  {
>         struct acpi_processor_cx *x = a, *y = b;
> -       u32 tmp;
>
>         if (!(x->valid && y->valid))
>                 return;
> -       tmp = x->latency;
> -       x->latency = y->latency;
> -       y->latency = tmp;
> +       swap(x->latency, y->latency);
>  }
>
>  static int acpi_processor_power_verify(struct acpi_processor *pr)
> --

Applied as 5.17 material with edited subject and changelog, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-24 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-09  7:50 [PATCH] ACPI: processor idle: fix swap.cocci warning Guo Zhengkui
2021-11-24 16:48 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).