Re: [cocci] Adjusting attributes for variables with SmPL?
Julia Lawall <[email protected]> Thu, 28 May 2026 18:48:16 +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-1391246794-1779986896=:10822 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Thu, 28 May 2026, Markus Elfring wrote: > >>> 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? > Please compare the involved SmPL code in more detail once more. > > > A) > @simple_display@ > expression E1, E2; > identifier F, X; > initialiser I; > type T; > @@ > *T F = I; > ... > *memcmp(&F.X, E1, E2) > > > Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch example_by_Pierrick_Philippe-20260527.c suggestion7_for_Pierrick_Philippe-20260528.cocci > … > diff = > … > > > B) > @adjusted_display@ > expression E1, E2; > identifier F, X; > initialiser I; > type T; > @@ > *T F = I; > ... > *memcmp( > ( &F.X, E1 > | E1, &F.X > ) , E2 > ) > > Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> /usr/bin/spatch example_by_Pierrick_Philippe-20260527.c suggestion6_for_Pierrick_Philippe-20260528.cocci > … > [no diff output] > > > Why does the application of such an SmPL disjunction seem to prevent > an expected difference display anyhow? The disjunction does not mean what you think it means. The C language contains a comma expression, alloowing you to put two expressions together with a comma in a place that one expression is expected. That is how your second semantic patch is being parsed. Memcmp is considered to be a two-argument expression where the first argument is a comma expression. That will not match any real call to memcmp, which is a three argument function. To reiterate, for expressions, a dijunction takes only one expression at a time. You can't randomly put a disjunction around some fragment of an argument list. julia --8323329-1391246794-1779986896=:10822--