On Wed, 3 Nov 2010, Michael T wrote:
>
> Hello,
>
> Your example isnull.cocci has the same problem with a missing test as I
> pointed
> out for mini_null_ref2.cocci in my previous posting.
OK, thanks for pointing it out.
> In addition, it doesn't seem
> to get for loops right - the following code:
>
> if (p1 == NULL) {
> for(p1 = p2; p1 != NULL; p1 = p1->next) {
Coccinelle doesn't have any notion of the control flow between the parts
of a for loop header.
One possible fix would be to write the first rule as follows:
@r exists@
expression E, E1;
identifier f,f1;
statement S1,S2,S3;
position p;
@@
if (E == NULL)
{
... when != if (E == NULL) S1 else S2
when != f1(...,&E,...)
(
E = E1
|
e...@p->f
)
... when any
return ...;
}
else S3
Or to be even more safe, the pattern part could be:
if (E == NULL)
{
... when != if (E == NULL) S1 else S2
when != f1(...,&E,...)
(
E = (<+... e...@p->f ...+>)
|
E = E1
|
e...@p->f
)
... when any
return ...;
}
else S3
julia_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)