lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y8Zf+tdh8xr6nviC@osiris>
Date:   Tue, 17 Jan 2023 09:44:42 +0100
From:   Heiko Carstens <hca@...ux.ibm.com>
To:     Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Cc:     agordeev@...ux.ibm.com, gerald.schaefer@...ux.ibm.com,
        gor@...ux.ibm.com, borntraeger@...ux.ibm.com, svens@...ux.ibm.com,
        linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
        Abaci Robot <abaci@...ux.alibaba.com>
Subject: Re: [PATCH] s390/vmem: Use swap() instead of open coding it

On Tue, Jan 17, 2023 at 02:02:23PM +0800, Jiapeng Chong wrote:
> Swap is a function interface that provides exchange function. To avoid
> code duplication, we can use swap function.
> 
> ./arch/s390/mm/vmem.c:680:10-11: WARNING opportunity for swap().
> 
> Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3786
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> ---
>  arch/s390/mm/vmem.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
> index 78d7768f93d7..774a71b94f5c 100644
> --- a/arch/s390/mm/vmem.c
> +++ b/arch/s390/mm/vmem.c
> @@ -674,11 +674,8 @@ static void __init memblock_region_swap(void *a, void *b, int size)
>  {
>  	struct memblock_region *r1 = a;
>  	struct memblock_region *r2 = b;
> -	struct memblock_region swap;
>  
> -	swap = *r1;
> -	*r1 = *r2;
> -	*r2 = swap;
> +	swap(*r1, *r2);
>  }

Let's remove r1, and r2 as well. I applied the below:

>From ff3ebe76f3b9481e6553bc2f05b52a266cd2e4a5 Mon Sep 17 00:00:00 2001
From: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Date: Tue, 17 Jan 2023 14:02:23 +0800
Subject: [PATCH] s390/vmem: 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/s390/mm/vmem.c:680:10-11: WARNING opportunity for swap().

[hca@...ux.ibm.com: get rid of all temp variables]
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=3786
Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Link: https://lore.kernel.org/r/20230117060223.58583-1-jiapeng.chong@linux.alibaba.com
Signed-off-by: Heiko Carstens <hca@...ux.ibm.com>
---
 arch/s390/mm/vmem.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index 78d7768f93d7..15daf777cf41 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -672,13 +672,7 @@ static int __init memblock_region_cmp(const void *a, const void *b)
 
 static void __init memblock_region_swap(void *a, void *b, int size)
 {
-	struct memblock_region *r1 = a;
-	struct memblock_region *r2 = b;
-	struct memblock_region swap;
-
-	swap = *r1;
-	*r1 = *r2;
-	*r2 = swap;
+	swap(*(struct memblock_region *)a, *(struct memblock_region *)b);
 }
 
 /*
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ