From: Wei Liu <wei.liu@kernel.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-hyperv@vger.kernel.org, x86@kernel.org,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Dexuan Cui <decui@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Long Li <longli@microsoft.com>,
Mukesh Rathor <mrathor@linux.microsoft.com>,
Thomas Gleixner <tglx@linutronix.de>,
Wei Liu <wei.liu@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Miaoqian Lin <linmq006@gmail.com>
Subject: Re: [PATCH] x86/hyperv: Use pointer from memcpy() call for assignment in hv_crash_setup_trampdata()
Date: Fri, 31 Oct 2025 18:26:15 +0000 [thread overview]
Message-ID: <20251031182615.GB2612078@liuwe-devbox-debian-v2.local> (raw)
In-Reply-To: <d209991b-5aee-4222-aec3-cb662ccb7433@web.de>
On Fri, Oct 31, 2025 at 09:33:17AM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 31 Oct 2025 09:24:31 +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/x86/hyperv/hv_crash.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/x86/hyperv/hv_crash.c b/arch/x86/hyperv/hv_crash.c
> index c0e22921ace1..745d02066308 100644
> --- a/arch/x86/hyperv/hv_crash.c
> +++ b/arch/x86/hyperv/hv_crash.c
> @@ -464,9 +464,7 @@ static int hv_crash_setup_trampdata(u64 trampoline_va)
> return -1;
> }
>
> - dest = (void *)trampoline_va;
> - memcpy(dest, &hv_crash_asm32, size);
> -
> + dest = memcpy((void *)trampoline_va, &hv_crash_asm32, size);
I don't think this change is needed.
There aren't that many places in the kernel tree that use this pattern.
The pattern used by the original code is far more pervasive.
Wei
> dest += size;
> dest = (void *)round_up((ulong)dest, 16);
> tramp = (struct hv_crash_tramp_data *)dest;
> --
> 2.51.1
>
prev parent reply other threads:[~2025-10-31 18:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-31 8:33 [PATCH] x86/hyperv: Use pointer from memcpy() call for assignment in hv_crash_setup_trampdata() Markus Elfring
2025-10-31 9:28 ` Naman Jain
2025-10-31 9:37 ` Julia Lawall
2025-10-31 9:44 ` Markus Elfring
2025-10-31 12:32 ` Naman Jain
2025-10-31 18:26 ` Wei Liu [this message]
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=20251031182615.GB2612078@liuwe-devbox-debian-v2.local \
--to=wei.liu@kernel.org \
--cc=Markus.Elfring@web.de \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linmq006@gmail.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=mingo@redhat.com \
--cc=mrathor@linux.microsoft.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).