Re: [cocci] [RFC] Increasing usage of direct pointer assignments from memcpy() calls with SmPL?

From: Julia Lawall

Date: Thu Oct 30 2025 - 06:32:03 EST




On Thu, 30 Oct 2025, Markus Elfring wrote:

> …> I think you would get a more satisfactory result by just removing all of
> > the code and adding it back. Then Coccinelle would take charge of laying
> > out the whole thing.
>
>
> See also once more:
>
> >> Another SmPL script example might become helpful.
> >>
> >> @replacement2@
> >> expression object, size, source, target;
> >> @@
> >> target =
> >> - object; memcpy(target, source, size)
> >> + memcpy(object, source, size)
> >> ;

I said to remove everything. target = also.

julia

> >>
> >>
> >> Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --max-width 100 --no-loops …/Projekte/Coccinelle/janitor/use_memcpy_assignment2.cocci arch/arm64/kvm/arm.c
> …>> real 0m0,626s
> >> user 0m0,588s
> >> sys 0m0,037s
>
>
> Regards,
> Markus
>