Re: [cocci] Adjusting attributes for variables with SmPL?

Julia Lawall <[email protected]> Thu, 28 May 2026 16:31:36 +0200 (CEST)
Newsgroups fr.inria.cocci
Message-ID <[email protected]>
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--8323329-918906078-1779978696=:10822
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8BIT



On Thu, 28 May 2026, Markus Elfring wrote:

> >> How does the shown message fit to the presented SmPL script?
>
> Another SmPL script variant can point interesting data processing design options out,
> can't it?
>
> @initialize:python@
> @@
> mark = ['"', '', '"']
>
> @searching@
> expression E1, E2;
> identifier F, X;
> initialiser I;
> type T;
> @@
>  T F = I;
>  ...
>  memcmp(
> (       &F.X, E1
> |       E1, &F.X
> )       , E2
>        )
>
> @script:python generation@
> x << searching.X;
> my_string;
> @@
> mark[1] = x
> coccinelle.my_string = ''.join(mark)
>
> @replacement@
> expression searching.E1, searching.E2;
> identifier searching.F, searching.X, generation.my_string;
> initialiser searching.I;
> type searching.T;
> @@
>  T
> +__attribute__((myattr(
> +my_string
> +)))
>  F = I;
>  ...
>  memcmp(
> (       &F.X, E1
> |       E1, &F.X
> )       , E2
>        )
>
>
> > What message?
>
> I imagine that questionable data displays will occasionally be reproduced.
>
>
> >                The question is whether it makes the change that is wanted?
>
> Unfortunately, not with this test case.

And with the semantic patch that you sent previously before deciding to
"optimize" it?

julia

>
>
> Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch --no-loops example_by_Pierrick_Philippe-20260527.c suggestion5_for_Pierrick_Philippe-20260528.cocci
> …
> warning: replacement: inherited metavariable my_string not used in the -, +, or context code
> HANDLING: example_by_Pierrick_Philippe-20260527.c
> [no diff output]
>
>
> > Maybe the check for whether variables are used doesn't look in arrtibute
> > arguments.
>
> Will the motivation grow to achieve further software improvements?
>
> Regards,
> Markus
>
--8323329-918906078-1779978696=:10822--