linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ia64: module: use swap() to make code cleaner
@ 2021-11-18  6:20 cgel.zte
  2021-11-18 10:43 ` John Paul Adrian Glaubitz
  0 siblings, 1 reply; 3+ messages in thread
From: cgel.zte @ 2021-11-18  6:20 UTC (permalink / raw)
  To: akpm; +Cc: slyfox, linux-ia64, linux-kernel, Yao Jing, Zeal Robot

From: Yao Jing <yao.jing2@zte.com.cn>

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

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yao Jing <yao.jing2@zte.com.cn>
---
 arch/ia64/kernel/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 2cba53c1da82..360f36b0eb3f 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -848,7 +848,7 @@ register_unwind_table (struct module *mod)
 {
 	struct unw_table_entry *start = (void *) mod->arch.unwind->sh_addr;
 	struct unw_table_entry *end = start + mod->arch.unwind->sh_size / sizeof (*start);
-	struct unw_table_entry tmp, *e1, *e2, *core, *init;
+	struct unw_table_entry *e1, *e2, *core, *init;
 	unsigned long num_init = 0, num_core = 0;
 
 	/* First, count how many init and core unwind-table entries there are.  */
@@ -865,9 +865,7 @@ register_unwind_table (struct module *mod)
 	for (e1 = start; e1 < end; ++e1) {
 		for (e2 = e1 + 1; e2 < end; ++e2) {
 			if (e2->start_offset < e1->start_offset) {
-				tmp = *e1;
-				*e1 = *e2;
-				*e2 = tmp;
+				swap(*e1, *e2);
 			}
 		}
 	}
-- 
2.25.1


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

* Re: [PATCH] ia64: module: use swap() to make code cleaner
  2021-11-18  6:20 [PATCH] ia64: module: use swap() to make code cleaner cgel.zte
@ 2021-11-18 10:43 ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 3+ messages in thread
From: John Paul Adrian Glaubitz @ 2021-11-18 10:43 UTC (permalink / raw)
  To: cgel.zte, akpm; +Cc: slyfox, linux-ia64, linux-kernel, Yao Jing, Zeal Robot

Hi!

On 11/18/21 07:20, cgel.zte@gmail.com wrote:
> From: Yao Jing <yao.jing2@zte.com.cn>
> 
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Yao Jing <yao.jing2@zte.com.cn>
> ---
>  arch/ia64/kernel/module.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
> index 2cba53c1da82..360f36b0eb3f 100644
> --- a/arch/ia64/kernel/module.c
> +++ b/arch/ia64/kernel/module.c
> @@ -848,7 +848,7 @@ register_unwind_table (struct module *mod)
>  {
>  	struct unw_table_entry *start = (void *) mod->arch.unwind->sh_addr;
>  	struct unw_table_entry *end = start + mod->arch.unwind->sh_size / sizeof (*start);
> -	struct unw_table_entry tmp, *e1, *e2, *core, *init;
> +	struct unw_table_entry *e1, *e2, *core, *init;
>  	unsigned long num_init = 0, num_core = 0;
>  
>  	/* First, count how many init and core unwind-table entries there are.  */
> @@ -865,9 +865,7 @@ register_unwind_table (struct module *mod)
>  	for (e1 = start; e1 < end; ++e1) {
>  		for (e2 = e1 + 1; e2 < end; ++e2) {
>  			if (e2->start_offset < e1->start_offset) {
> -				tmp = *e1;
> -				*e1 = *e2;
> -				*e2 = tmp;
> +				swap(*e1, *e2);
>  			}
>  		}
>  	}

I will test this patch later this week.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


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

* [PATCH] ia64: module: use swap() to make code cleaner
@ 2021-11-04  6:26 davidcomponentone
  0 siblings, 0 replies; 3+ messages in thread
From: davidcomponentone @ 2021-11-04  6:26 UTC (permalink / raw)
  To: slyfox
  Cc: davidcomponentone, akpm, yang.guang5, linux-ia64, linux-kernel,
	Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

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

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 arch/ia64/kernel/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 2cba53c1da82..360f36b0eb3f 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -848,7 +848,7 @@ register_unwind_table (struct module *mod)
 {
 	struct unw_table_entry *start = (void *) mod->arch.unwind->sh_addr;
 	struct unw_table_entry *end = start + mod->arch.unwind->sh_size / sizeof (*start);
-	struct unw_table_entry tmp, *e1, *e2, *core, *init;
+	struct unw_table_entry *e1, *e2, *core, *init;
 	unsigned long num_init = 0, num_core = 0;
 
 	/* First, count how many init and core unwind-table entries there are.  */
@@ -865,9 +865,7 @@ register_unwind_table (struct module *mod)
 	for (e1 = start; e1 < end; ++e1) {
 		for (e2 = e1 + 1; e2 < end; ++e2) {
 			if (e2->start_offset < e1->start_offset) {
-				tmp = *e1;
-				*e1 = *e2;
-				*e2 = tmp;
+				swap(*e1, *e2);
 			}
 		}
 	}
-- 
2.30.2


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

end of thread, other threads:[~2021-11-18 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18  6:20 [PATCH] ia64: module: use swap() to make code cleaner cgel.zte
2021-11-18 10:43 ` John Paul Adrian Glaubitz
  -- strict thread matches above, loose matches on Subject: below --
2021-11-04  6:26 davidcomponentone

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).