On 11/08/2010 11:20 PM, Michael Stefaniuc wrote:
On 11/08/2010 10:30 PM, Julia Lawall wrote:
Currently the only solution is to enumerate the various kinds of
statements you are interested in. A small problem here is that do ...
while never got added to SmPL, so there is no way to specify that. You
can use position variables to mark all of the calls that get treated and
then make another rule that searches for any call that is not marked by
the position variable, eg:
@r@
expression e;
position p;
@@
+lock()
e =<+...c...@p()...+>;
+unlock()
@@
position p != r.p;
@@
- c...@p()
+ BAD(call())
You can also say position p != {r.p,s.p,x.p,...}; if there are multiple
position variables you want to compare with.
There is a problem with enumerating the bad cases. All need to depend on
not matching the good case
@ good @
identifier IWineD3D ~= "^IWineD3D.*";
position p;
@@
wined3d_mutex_lock();
<... iwine...@p( ... ) ...>
wined3d_mutex_unlock();
As soon as I add a second rule with position p != good.p;
I'll get an error:
Fatal error: exception Failure("meta: semantic error: position cannot be
inherited over modifications: p
@ bad1 @
identifier IWineD3D ~= "^IWineD3D.*";
position p != good.p;
@@
+ wined3d_mutex_lock();
iwine...@p( ... );
+ wined3d_mutex_unlock();
@ bad2 @
identifier IWineD3D ~= "^IWineD3D.*";
position p != good.p;
expression E;
@@
+ wined3d_mutex_lock();
E = iwine...@p( ... );
+ wined3d_mutex_unlock();
I wanted to kick myself for not using a single rule for bad1 and bad2
@ bad @
identifier IWineD3D ~= "^IWineD3D.*";
position p != good.p;
expression E;
@@
+ wined3d_mutex_lock();
(
iwine...@p( ... );
|
E = iwine...@p( ... );
)
+ wined3d_mutex_unlock();
but that gives an error too:
Fatal error: exception Failure("14: no available token to attach to")
While I can understand why <... iwine...@p( ... ) ...> would give that
error I don't see what is ambiguous about this rule.
thanks
bye
michael
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)