On Sun, 12 Apr 2020, Markus Elfring wrote:

> >> I hope that another clarification can be achieved also for the software
> >> behaviour of the following source code analysis approach.
> >
> > I don't run code that involves databases.  If you believe that there is a
> > problem with the semantic patch, you have to make a small version that
> > illustrates the problem.
>
> Would you find the test result easier to clarify for the following
> SmPL script example?
>
>
> @display1@
> expression action, e;
> position p;
> statement is, es;
> @@
> *e = action(...);
>  if@p (<+... e ...+>)
>     is
>  else
>     es
>
> @display2@
> expression check;
> position display1.p;
> statement display1.is, display1.es;

The problem is that you inherit es.  Since you inherit it, Coccinelle
considers that its presence is important, and so the isomorphism will not
eliminate it.  It is sufficient to make another pattern for the case with
no else.

julia

> @@
> *if@p (check)
>     is
>  else
>     es
>
>
> elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci 
> show_condition_checks_after_function_calls2.cocci
> …
> warning: iso drop_else does not match the code below on line 17
> if@p (check) iselse es
> …
>
>
> Will any software improvements become interesting for such an use case?
>
> Regards,
> Markus
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to