linux-alpha.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] alpha: Use pointers from memcpy() calls for assignments in two functions
@ 2025-10-30 16:35 Markus Elfring
  2025-10-31 12:51 ` kernel test robot
  2025-11-29 13:46 ` Magnus Lindholm
  0 siblings, 2 replies; 6+ messages in thread
From: Markus Elfring @ 2025-10-30 16:35 UTC (permalink / raw)
  To: linux-alpha, Chen Gang, Matt Turner, Richard Henderson
  Cc: LKML, kernel-janitors, Miaoqian Lin

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 30 Oct 2025 17:24:27 +0100

A pointer was assigned to a variable in two function implementations.
The same pointer was used for the destination parameter of a memcpy() call.
This function is documented in the way that the same value is returned.
Thus convert two separate statements into a direct variable assignment for
the return value from a memory copy action.

The source code was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/alpha/kernel/smp.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index ed06367ece57..8c7bc3ea7612 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -214,8 +214,7 @@ send_secondary_console_msg(char *str, int cpuid)
 	cp2 = str;
 	len = strlen(cp2);
 	*(unsigned int *)&cpu->ipc_buffer[0] = len;
-	cp1 = (char *) &cpu->ipc_buffer[1];
-	memcpy(cp1, cp2, len);
+	cp1 = memcpy(&cpu->ipc_buffer[1], cp2, len);
 
 	/* atomic test and set */
 	wmb();
@@ -265,8 +264,7 @@ recv_secondary_console_msg(void)
 			strcpy(buf, "<<< BOGUS MSG >>>");
 		else {
 			cp1 = (char *) &cpu->ipc_buffer[1];
-			cp2 = buf;
-			memcpy(cp2, cp1, cnt);
+			cp2 = memcpy(buf, cp1, cnt);
 			cp2[cnt] = '\0';
 			
 			while ((cp2 = strchr(cp2, '\r')) != 0) {
-- 
2.51.1


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

end of thread, other threads:[~2025-11-29 17:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-30 16:35 [PATCH] alpha: Use pointers from memcpy() calls for assignments in two functions Markus Elfring
2025-10-31 12:51 ` kernel test robot
2025-11-29 13:46 ` Magnus Lindholm
2025-11-29 15:50   ` Markus Elfring
2025-11-29 16:55   ` [PATCH] " Dan Carpenter
2025-11-29 17:33     ` Magnus Lindholm

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