Thanks for explain, but if I want to write a simple match, that is function foo 
must be called in main()
e.g.

int main(...)
{
    ...
    Foo(...);
    ...
}

I write it as

@@
@@
main(...) {
  <...
    when != reg_process_exit_action(...)
  ...>
}

Reports: 53 57
Fatal error: exception Failure("minus: parse error: 
 = File "rgos.cocci", line 6, column 2,  charpos = 53
    around = '...>', whole content =   ...>
")

What does it mean? 

By the way, I still don’t know when I should use '<'and'>' and when need not?

-----邮件原件-----
发件人: Julia Lawall [mailto:[email protected]] 
发送时间: 2014年1月27日 20:34
收件人: 林嘉(程二 福州)
抄送: [email protected]
主题: Re: 答复: [Cocci] how to write such matching case?

On Mon, 27 Jan 2014, 林嘉(程二 福州) wrote:

> I wrote this
> 
> @@
> @@
> cli_printf(...)
> ... when != cli_client_execmd_fail(...)
> 
> 
> it reports:
> Fatal error: exception Failure("False should not be in the final 
> result.  Perhaps your rule doesn't contain any +/-/* code, or you have 
> a failed dependency.")
> 
> 
> But i found there is not 'minus' in an example.cocci either....

There is a * (indicating a line of interest).  You can use that.  If you use 
that, you will get an exists semantics for the ... (there exists an execution 
path that satisfies the property).  Otherwise, you get a foral semantics (all 
execution paths have to satisfy the property).

julia

> 
> 
> //
> //  Add missing pci_dev_put
> //
> // Target: Linux
> // Copyright:  2012 - LIP6/INRIA
> // License:  Licensed under ISC. See LICENSE or 
> http://www.isc.org/software/license
> // Author: Julia Lawall <[email protected]> // URL: 
> http://coccinelle.lip6.fr/ // URL: http://coccinellery.org/
> 
> @@
> local idexpression x;
> expression e;
> @@
> 
> *x = pci_get_slot(...)
> ... when != true x == NULL
>     when != pci_dev_put(x)
>     when != e = x
>     when != if (x != NULL) {<+... pci_dev_put(x); ...+>} *return ...;
> 
> 
> 
> 
> 
> -----邮件原件-----
> 发件人: Julia Lawall [mailto:[email protected]]
> 发送时间: 2014年1月26日 19:19
> 收件人: 林嘉(程二 福州)
> 抄送: [email protected]
> 主题: Re: [Cocci] how to write such matching case?
> 
> On Sun, 26 Jan 2014, 林嘉(程二 福州) wrote:
> 
> > In my project, it's required that if function A is called, and 
> > function B must be called following, just like this
> >
> > Foo(...)
> > {
> >    If ... {
> >        A(....);
> >        ...
> >        B(....);
> >    }
> > }
> >
> > Or
> >
> > Foo1(...)
> > {
> >         A(....);
> >         B(...);
> >  }
> >
> >
> > How to write a patch to find the missing case? Such as
> >
> > Foo(...)
> > {
> >    If ... {
> >        A(....);
> >        ...
> >    }
> > }
> >
> > Or
> >
> > Foo1(...)
> > {
> >        A(....);
> >        ...
> > }
> 
> A(...)
> ... When != B(...)
> 
> julia
> 
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to