Skip to contentSkip to conversation

MIPS: Loongson64: Use pointer from memcpy() call for assignment in loongson_kexec_prepare()

PATCH In review Markus Elfring 2 participants 2 messages Oct 30, 2025 – Oct 31, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: Loongson64: Use pointer from memcpy() call for assignment in loongson_kexec_prepare()

From: Markus Elfring <[email protected]>
Date: Thu, 30 Oct 2025 20:48:11 +0100

A pointer was assigned to a variable. 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.

---
 arch/mips/loongson64/reset.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/mips/loongson64/reset.c +3 -2
index 3e20ade0503a..ce412f5616b7 100644
@@ -76,8 +76,9 @@ static int loongson_kexec_prepare(struct kimage *image)
 			 * of parameters (as bootloader does).
 			 */
 			int offt;
-			str = (char *)argv + KEXEC_ARGV_SIZE/2;
-			memcpy(str, image->segment[i].buf, KEXEC_ARGV_SIZE/2);
+
+			str = memcpy((char *)argv + KEXEC_ARGV_SIZE / 2, image->segment[i].buf,
+				     KEXEC_ARGV_SIZE / 2);
 			ptr = strchr(str, ' ');
 
 			while (ptr && (argc < MAX_ARGS)) {
Signature · 1 line
2.51.1
#1 lore raw
Quoted 10 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 30 Oct 2025 20:48:11 +0100

A pointer was assigned to a variable. 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.

Just looking at this change, I think this obscures things more than clarifies things.

I believe the separate variable was used as much as anything to make the line lengths shorter and the code more readable.

Eric

Quoted 21 lines
---
 arch/mips/loongson64/reset.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/mips/loongson64/reset.c +3 -2
index 3e20ade0503a..ce412f5616b7 100644
@@ -76,8 +76,9 @@ static int loongson_kexec_prepare(struct kimage *image)
 			 * of parameters (as bootloader does).
 			 */
 			int offt;
-			str = (char *)argv + KEXEC_ARGV_SIZE/2;
-			memcpy(str, image->segment[i].buf, KEXEC_ARGV_SIZE/2);
+
+			str = memcpy((char *)argv + KEXEC_ARGV_SIZE / 2, image->segment[i].buf,
+				     KEXEC_ARGV_SIZE / 2);
 			ptr = strchr(str, ' ');
 
 			while (ptr && (argc < MAX_ARGS)) {