> It should be possible to declare a metavariable to have any C type.

I have got the impression that meta-variables get a SmPL data type which
corresponds to syntax elements in the target language.
Are all (needed) elements already supported?


> For function types, though it doesn't seem to work in practice.

I'm sorry that I can not understand your hint so far.
Would you like to explain it a bit more?


> I don't think that giving a metavariable a function type is necessary for 
> doing this.  You can just match the declaration of the function itself.

How can I specify the desired filter expression if I do not know a concrete
function name?
Can a meta-variable provide the name for the affected function(s)?


> I'm not sure that a generally applicable transformation can be defined in 
> this case.  One would have to think a bit how the return value should be 
> used (eg tested, and what the impact of that test should be).

I would try to insert a function call like "exit(errno)" or "abort()" if the
target language is "C".
Otherwise: I would try to throw an exception in programming languages which
support them.


> Perhaps if one passes it to another function, that could be considered to 
> be good enough?

Not completely. - Can it be expressed in the semantic patch language that a
return value was assigned to a variable and not used in a conditional expression
or as a function parameter after that assignment?

How do you think about a concrete SmPL filter pattern application for a source
file where I pointed out corresponding open issues in a bug report "Check return
codes everywhere"?
http://www.cmake.org/Bug/view.php?id=11681
⇒ Source code example:
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/kwsys/ProcessUNIX.c;hb=b9e3c243d476efa04479d253cfc4f76ecbdb6fe3#l2713


> But if one wants to consider that case in a special way, it should be 
> possible to do that. 
> Eg f(...,x,...) where f is a metavariable will match any passing of x to some 
> function.

I see that you suggest the use of commas around the "x" (meta-)variable. Does
this also work at the beginning or end of the function parameter list?

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

Reply via email to