[Cocci] How to use coccinelle as a kind of grep -l ?
Nicholas Mc Guire
der.herr at hofr.at
Mon Dec 1 11:37:06 CET 2014
On Mon, 01 Dec 2014, Francois Berenger wrote:
> On 12/01/2014 11:12 AM, Francois Berenger wrote:
> Instead of applying ...
>> Inside of applying any patch, I need to use coccinelle
>> in order to detect certain C files that match a given pattern
>> in a source code tree.
>> Is it possible to use coccinelle for that, how?
here is a simple (hopefuly correct) example of a scanner - that will look
for inbalanced use of spinlocks and bh disable/enable - it reports one
line per file that matches giving the name and line-numbers of the
potentially inballanced calls.
p1 << r1.p1;
p2 << r1.p2;
p3 << r1.p3;
print "file:%s at lines %s %s %s" % (p1.file,p1.line, p2.line, p3.line)
put this in a file called scan.cocci and running with the below command
hofrat at debian:/usr/src/linux-next$ spatch --cocci-file /tmp/scan.cocci --dir net/core/
file:net/core/sock.c at lines 2396 2406 2411
file:net/core/sock.c at lines 2346 2350 2355
More information about the Cocci