[Cocci] Finding function implementations that call only a single function.

Julia Lawall julia.lawall at lip6.fr
Sun Dec 7 11:28:01 CET 2014


On Sun, 7 Dec 2014, SF Markus Elfring wrote:

> > OK, now the C file is manageable, if I drop the 20 lines of comments at 
> > the top of the file.
> > 
> > The following is also a completely understandable semantic patch:
> > 
> >> @single_function_call@
> >> identifier caller, input, work;
> >> type input_type, return_type;
> >> @@
> >> *return_type caller(input_type input)
> >>  {
> >> (
> >>   work(input);
> >> |
> >>   return work(input);
> >> )
> >>  }
> >>
> >> @single_function_call_with_pointer@
> >> identifier caller, element, input, work;
> >> type input_type, return_type;
> >> @@
> >> *return_type caller(input_type * input)
> >>  {
> >> (
> >>   work(input->element);
> >> |
> >>   return work(input->element);
> >> )
> >>  }
> > 
> > So, now what is the problem with the following output?
> 
> The source code output is not the problem from the application
> of such a small SmPL script.
> 
> I find that my filter patterns contain open issues here.
> 
> One part of each SmPL disjunction will always not match in this approach
> if an analysed function implementation has got the return type "void".
> Would the specification of a metavariable "return_type" be also
> unnecessary and inappropriate in this use case?

Currently, return_type does absolutely nothing.  You can just drop it.

> > Unless your pattern requires following a lot of different control-flow paths,
> > eg due to sequences of conditionals, the C code parsing time will massively
> > dominate the matching time.
> 
> The Coccinelle software has got difficulties with specific Linux source files
> so that it became safer to add the command line parameter "timeout" for example.
> 
> I can only directly influence the SmPL scripts here. So I try to make them as good
> and fast as I can. Other technical improvements will eventually need more efforts.

The changes you are considering will have no impact on whether timeout is 
needed.  If something requires eg 2000 seconds to complete, dropping 1 2 
or 100 seconds will have no noticible impact.

julia


More information about the Cocci mailing list