Re: [cocci] Adjusting attributes for variables with SmPL?
Julia Lawall <[email protected]> Thu, 28 May 2026 14:10:51 +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-2011483797-1779970252=:10822 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Thu, 28 May 2026, Markus Elfring wrote: > > You have declared content as an identifer and added it into a position > > where an identifier is not allowed. My suggestion was something like: > > > > coccinelle.content = "\"" + x + "\"" > > > > Or whatever is appropriate in pything for putting the value of x in string > > quotes. Then in the replacement rule you can put the whole > > __attribute((...)) construction. > > The following data processing approach is not accepted by the Coccinelle software > so far. Didn't I already explain why it didn't work and send an alternative? julia > > See also: > Propagating values back from Python script to SmPL rule with other metavariable type than “identifier” > 2016-10-21 > https://github.com/coccinelle/coccinelle/issues/86 > > > @searching@ > expression E1, E2; > identifier F, X; > initialiser I; > type T; > @@ > T F = I; > ... > memcmp(&F.X, E1, E2) > > @script:python generation@ > x << searching.X; > content; > @@ > coccinelle.content = "__attribute__((myattr(\"" + x + "\"))) " > > @replacement@ > expression searching.E1, searching.E2; > identifier searching.F, searching.X, generation.content; > initialiser searching.I; > type searching.T; > @@ > T > +content > F = I; > ... > memcmp(&F.X, E1, E2) > > > Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch --parse-cocci suggestion3_for_Pierrick_Philippe-20260528.cocci > init_defs_builtins: /usr/lib64/coccinelle/standard.h > plus: parse error: > File "suggestion3_for_Pierrick_Philippe-20260528.cocci", line 25, column 1, charpos = 402 > around = 'F', > whole content = F = I; > > > Will any contributors become more motivated for the safe construction of desirable > source code attributes? > > Regards, > Markus > --8323329-2011483797-1779970252=:10822--