* [PATCH] MIPS: Loongson64: Use pointer from memcpy() call for assignment in loongson_kexec_prepare()
@ 2025-10-30 19:57 Markus Elfring
2025-10-31 3:19 ` Eric W. Biederman
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2025-10-30 19:57 UTC (permalink / raw)
To: linux-mips, Huacai Chen, Jiaxun Yang, Jinyang He,
Thomas Bogendörfer, Youling Tang
Cc: LKML, kernel-janitors, Eric Biederman, Miaoqian Lin
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/mips/loongson64/reset.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/mips/loongson64/reset.c b/arch/mips/loongson64/reset.c
index 3e20ade0503a..ce412f5616b7 100644
--- a/arch/mips/loongson64/reset.c
+++ b/arch/mips/loongson64/reset.c
@@ -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)) {
--
2.51.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] MIPS: Loongson64: Use pointer from memcpy() call for assignment in loongson_kexec_prepare()
2025-10-30 19:57 [PATCH] MIPS: Loongson64: Use pointer from memcpy() call for assignment in loongson_kexec_prepare() Markus Elfring
@ 2025-10-31 3:19 ` Eric W. Biederman
0 siblings, 0 replies; 2+ messages in thread
From: Eric W. Biederman @ 2025-10-31 3:19 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-mips, Huacai Chen, Jiaxun Yang, Jinyang He,
Thomas Bogendörfer, Youling Tang, LKML, kernel-janitors,
Miaoqian Lin
Markus Elfring <Markus.Elfring@web.de> writes:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> arch/mips/loongson64/reset.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips/loongson64/reset.c b/arch/mips/loongson64/reset.c
> index 3e20ade0503a..ce412f5616b7 100644
> --- a/arch/mips/loongson64/reset.c
> +++ b/arch/mips/loongson64/reset.c
> @@ -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)) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-31 3:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-30 19:57 [PATCH] MIPS: Loongson64: Use pointer from memcpy() call for assignment in loongson_kexec_prepare() Markus Elfring
2025-10-31 3:19 ` Eric W. Biederman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox