linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Naman Jain <namjain@linux.microsoft.com>
Cc: Markus Elfring <Markus.Elfring@web.de>,
	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 10:37:00 +0100 (CET)	[thread overview]
Message-ID: <193768a-6914-5217-8815-ab1c75f1c8d@inria.fr> (raw)
In-Reply-To: <cea9d987-0231-4131-82ac-9ba8c852f963@linux.microsoft.com>



On Fri, 31 Oct 2025, Naman Jain wrote:

>
>
> On 10/31/2025 2:03 PM, 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);
> >   	dest += size;
> >   	dest = (void *)round_up((ulong)dest, 16);
> >   	tramp = (struct hv_crash_tramp_data *)dest;
>
>
> I tried running spatch Coccinelle checks on this file, but could not get it to
> flag this improvement. Do you mind sharing more details on the issue
> reproduction please.
>
> I am OK with this change, though it may cost code readability a little bit.
> But if this is a result of some known standard rule, added as part of these
> Coccinelle rules, we should be good.

Multiple people have suggested that due to the loos of readability the
change is not a good idea.

It's not done by a standard rule.

julia



  reply	other threads:[~2025-10-31  9:37 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 [this message]
2025-10-31  9:44   ` Markus Elfring
2025-10-31 12:32     ` Naman Jain
2025-10-31 18:26 ` Wei Liu

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=193768a-6914-5217-8815-ab1c75f1c8d@inria.fr \
    --to=julia.lawall@inria.fr \
    --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=namjain@linux.microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=wei.liu@kernel.org \
    --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).