From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Markus Elfring <Markus.Elfring@web.de>,
linuxppc-dev@lists.ozlabs.org, Dmitry Vyukov <dvyukov@google.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Miaoqian Lin <linmq006@gmail.com>
Subject: Re: [PATCH] powerpc/cputable: Use pointer from memcpy() call for assignment in set_cur_cpu_spec()
Date: Tue, 4 Nov 2025 10:34:26 +0100 [thread overview]
Message-ID: <3115e03a-1995-46f4-a902-47ba3cb99901@csgroup.eu> (raw)
In-Reply-To: <6c61cf90-5811-4450-b649-7a2c84584ee9@web.de>
Le 30/10/2025 à 21:15, Markus Elfring a écrit :
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 30 Oct 2025 21:10: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.
I can't see the added value of this change. For me it degrades
readability. Many places in cputable.c have that t = PTRRELOC(t)
pattern, I can't see why that one should be changed while other ones remain.
Can you elaborate why this change is desirable ?
Thanks
Christophe
>
> The source code was transformed by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> arch/powerpc/kernel/cputable.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
> index 6f6801da9dc1..a69ea88b780f 100644
> --- a/arch/powerpc/kernel/cputable.c
> +++ b/arch/powerpc/kernel/cputable.c
> @@ -34,12 +34,11 @@ void __init set_cur_cpu_spec(struct cpu_spec *s)
> {
> struct cpu_spec *t = &the_cpu_spec;
>
> - t = PTRRELOC(t);
> /*
> * use memcpy() instead of *t = *s so that GCC replaces it
> * by __memcpy() when KASAN is active
> */
> - memcpy(t, s, sizeof(*t));
> + t = memcpy(PTRRELOC(t), s, sizeof(*t));
>
> *PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
> }
next prev parent reply other threads:[~2025-11-04 9:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 20:15 Markus Elfring
2025-11-04 9:34 ` Christophe Leroy [this message]
2025-11-04 11:48 ` Markus Elfring
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=3115e03a-1995-46f4-a902-47ba3cb99901@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=Markus.Elfring@web.de \
--cc=dvyukov@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linmq006@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
/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
all inboxes | Powered by JetHome®