Skip to contentSkip to conversation

Support for position variables on comparison operators with SmPL isomorphisms?

cocci Markus Elfring 2 participants 3 messages Jul 5, 2025

lore
Share & tools
lore
#0 lore raw

Hello,

I would like to attach a position variable to a comparison operator in another script for the semantic patch language.

@x depends on org || report@
expression limit;
identifier i;
position p;
statement s;
@@
for (

      <+... i = 0 ...+> ;
      i <=@p limit
      ;
      <+...
(     i++
|     ++i
)     ...+>
     )

s

Unfortunately, I got the following information (by the software combination “Coccinelle 1.3.0”) for further considerations.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/b00c5adb1a485321c88450bdaa9e0d9ff93123dc/standard.iso#L316-329

Markus_Elfring@Sonne:…/Projekte/Linux/next2-patched> /usr/bin/spatch --parse-cocci -D report scripts/coccinelle/misc/show_questionable_count_limit_checks.cocci …
warning: iso gtr_lss_eq does not match the code below on line 50
bool (i <=@p limit)

position variable x.p conflicts with an isomorphism …

Will any more software adjustments become desirable accordingly?

Regards,
Markus

#1 lore raw
Quoted 33 lines · Markus Elfring

Hello,

I would like to attach a position variable to a comparison operator in another script for the semantic patch language.

@x depends on org || report@
expression limit;
identifier i;
position p;
statement s;
@@
for (

      <+... i = 0 ...+> ;
      i <=@p limit
      ;
      <+...
(     i++
|     ++i
)     ...+>
     )

s

Unfortunately, I got the following information (by the software combination “Coccinelle 1.3.0”) for further considerations.
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/b00c5adb1a485321c88450bdaa9e0d9ff93123dc/standard.iso#L316-329

Markus_Elfring@Sonne:…/Projekte/Linux/next2-patched> /usr/bin/spatch --parse-cocci -D report scripts/coccinelle/misc/show_questionable_count_limit_checks.cocci …
warning: iso gtr_lss_eq does not match the code below on line 50
bool (i <=@p limit)

Quoted 5 lines

position variable x.p conflicts with an isomorphism …

Will any more software adjustments become desirable accordingly?

No. If you want the position of something, it seems that you want the position of that thing, not something else. So the position variable prevents the isomorphism.

julia

Quoted 4 lines

Regards,
Markus

#2 lore raw
Quoted 5 lines
Quoted 1 line

Will any more software adjustments become desirable accordingly?

No. If you want the position of something, it seems that you want the position of that thing, not something else. So the position variable prevents the isomorphism.

Can the change tolerance be adjusted anyhow also according to mentioned transformations because of SmPL isomorphisms?

Will positional extensions become helpful?

Regards,
Markus