The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-alpha@vger.kernel.org, Chen Gang <gang.chen@asianux.com>,
	Matt Turner <mattst88@gmail.com>,
	Richard Henderson <richard.henderson@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Miaoqian Lin <linmq006@gmail.com>
Subject: [PATCH] alpha: Use pointers from memcpy() calls for assignments in two functions
Date: Thu, 30 Oct 2025 17:35:27 +0100	[thread overview]
Message-ID: <1605dd43-5e95-46eb-a0c6-78ff8b4d51b3@web.de> (raw)

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


             reply	other threads:[~2025-10-30 16:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-30 16:35 Markus Elfring [this message]
2025-10-31 12:51 ` [PATCH] alpha: Use pointers from memcpy() calls for assignments in two functions 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1605dd43-5e95-46eb-a0c6-78ff8b4d51b3@web.de \
    --to=markus.elfring@web.de \
    --cc=gang.chen@asianux.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linmq006@gmail.com \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox