Hello again, Here is a semantic patch:
---- @r@ identifer f; local idexpression victim; position p; @@ amfree@p(victim) ... when != victim @script:python depends on r@ victim << r.victim; p << r.p; @@ print "%s, line %s: local variable %s is amfree()d but isn't used anywhere else in the file" % (p[0].file, p[0].line, str(victim)) ---- Now, I have one problem and one question: - the problem is, it also prints the warning if "victim" is static, which I don't want: how do I tell it about that? - the question is, I also want to print the name of the enclosing function and where it is defined, how do I do that? Have fun, -- Francis Galiegue, [email protected] "It seems obvious [...] that at least some 'business intelligence' tools invest so much intelligence on the business side that they have nothing left for generating SQL queries" (Stéphane Faroult, in "The Art of SQL", ISBN 0-596-00894-5) _______________________________________________ Cocci mailing list [email protected] http://lists.diku.dk/mailman/listinfo/cocci (Web access from inside DIKUs LAN only)
