On Wed, 12 Feb 2014, 林嘉(程二 福州) wrote:

> You mean this?
> 
> @forall@
> @@
> * main(){

I've lost track of the issue, but here you have () as your parameter list 
and in the code there is a void.  If you want void, you need to put void.  
If you don't care about the contents of the parameter list, you should put 
...

julia

>    ...when != reg_process_exit_action(...)
> }
> 
> And my 'main' function is straightforward without flow control
> 
> int main(void)
> {
>     struct AAAA foo;
>     struct AAA foo2;
>     struct BBB foo3, *p;
>     printf("%d\n", sizeof(((struct AAAA*)0)->aa));
>     printf("%d %d %d\n", foo.aa.c, foo2.c, foo3.value); 
>     memset(p, 0, sizeof(*p));    
>     reg_process_exit_action(0, RESTART);    
>     return 0;
> }
> 
> 
> 
> -----邮件原件-----
> 发件人: Julia Lawall [mailto:[email protected]] 
> 发送时间: 2014年1月28日 15:25
> 收件人: 林嘉(程二 福州)
> 抄送: Peter Senna Tschudin; [email protected]
> 主题: Re: 答复: [Cocci] 答复: 答复: how to write such matching case?
> 
> 
> 
> On Tue, 28 Jan 2014, 林嘉(程二 福州) wrote:
> 
> > Just like this?
> > @@
> > @@
> > * main(...){
> >    ...when != reg_process_exit_action(...) }
> > 
> > 
> > I tried, but it seems does not work...
> > 
> > I make the function reg...() called in main(), but it still report 
> > main()
> 
> Probably because there exists a control flow path in which it is not called.  
> If you want the forall semantics, put forall in between the initial @@
> 
> julia
> 
> 
> > 
> > -----邮件原件-----
> > 发件人: Peter Senna Tschudin [mailto:[email protected]]
> > 发送时间: 2014年1月27日 22:12
> > 收件人: 林嘉(程二 福州)
> > 抄送: Julia Lawall; [email protected]
> > 主题: Re: [Cocci] 答复: 答复: how to write such matching case?
> > 
> > You can try:
> > 
> > @@
> > @@
> > * main () {
> >    ...
> >    when != Foo(...)
> > }
> > 
> > This semantic patch will match functions named main that do not 
> > contain call to function Foo;
> > 
> > On Mon, Jan 27, 2014 at 2:55 PM, 林嘉(程二 福州) <[email protected]> wrote:
> > > 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
> > 
> > 
> > 
> > --
> > Peter
> > 
> 
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to