Please put when any on the ...

julia

On Fri, 23 Dec 2011, SF Markus Elfring wrote:

Why don't you just put a * in the is_assigned rule?

How do you think about the following analysis result for another source code example?

elfring@Sonne:~/Projekte/Coccinelle/Probe> SRC=f-ptr-test2.c && cat $SRC && LINE='-----' && echo $LINE && PAT=assignment_pattern6.cocci && cat $PAT && echo $LINE && spatch -sp_file $PAT $SRC
int my_addition(char a, char b)
{
 return a + b;
}

int main(void)
{
 struct my_operations
 {
   int (*add)(char a, char b);
 } mo = {my_addition}, * mop = &mo;

 int y = mop->add(8, 9);
 y = mop->add(1, 2);
 y = mo.add(3, 4);
 y = mo.add(5, 6);
 y = mop->add(7, 8);
}
-----
@is_assigned@
type t;
expression x, y;
expression f != {strcpy, strcat, fread, fclose, add, log};
statement S1, S2, S3, S4;
@@
*y = (t) (x)(...)
... when != if (<+...y...+>) S1 else S2
    when != (f)(...,<+...y...+>,...)
    when != for (...;<+...y...+>;...) S3
    when != while (<+...y...+>) S4
    when != switch (<+...y...+>) { case ... : ... }
    when != (<+...y...+>) ? ... : ...
-----
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: f-ptr-test2.c
diff =
--- f-ptr-test2.c
+++ /tmp/cocci-output-14409-e16bd8-f-ptr-test2.c
@@ -14,5 +14,4 @@ int main(void)
  y = mop->add(1, 2);
  y = mo.add(3, 4);
  y = mo.add(5, 6);
-  y = mop->add(7, 8);
}


Regards,
Markus

_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to