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 tried to hint to coccinelle that p didn't change in a way to affect rule bad2:
@ bad2 depends on !bad1 @
and
position p != {bad.p,good.p};
But without success. Of course I can add a new good rule after each bad rule but it gets ugly pretty soon.

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

Reply via email to