Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 227680
b: refs/heads/master
c: a1087ef
h: refs/heads/master
v: v3
  • Loading branch information
Julia Lawall authored and Michal Marek committed Dec 3, 2010
1 parent dc5d5bd commit ad0fd58
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0a18a9386c056028799938960f91be338c4ff349
refs/heads/master: a1087ef6abedf0bfd60e5e3fddf33192cb2c1325
4 changes: 4 additions & 0 deletions trunk/Documentation/coccinelle.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ as a regular user, and install it with

sudo make install

The semantic patches in the kernel will work best with Coccinelle version
0.2.4 or later. Using earlier versions may incur some parse errors in the
semantic patch code, but any results that are obtained should still be
correct.

Using Coccinelle on the Linux kernel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
6 changes: 3 additions & 3 deletions trunk/scripts/coccinelle/misc/doubleinit.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
// URL: http://coccinelle.lip6.fr/
// Comments:
// Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise
// Options: -no_includes -include_headers

virtual org
Expand All @@ -19,15 +19,15 @@ position p0,p;
expression E;
@@

struct I s =@p0 { ... .fld@p = E, ...};
struct I s =@p0 { ..., .fld@p = E, ...};

@s@
identifier I, s, r.fld;
position r.p0,p;
expression E;
@@

struct I s =@p0 { ... .fld@p = E, ...};
struct I s =@p0 { ..., .fld@p = E, ...};

@script:python depends on org@
p0 << r.p0;
Expand Down
39 changes: 14 additions & 25 deletions trunk/scripts/coccinelle/null/deref_null.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,10 @@
// Options:

virtual context
virtual patch
virtual org
virtual report

@initialize:python depends on !context && patch && !org && !report@
import sys
print >> sys.stderr, "This semantic patch does not support the 'patch' mode."
@depends on patch@
@@
this_rule_should_never_matches();
@ifm depends on !patch@
@ifm@
expression *E;
statement S1,S2;
position p1;
Expand All @@ -35,15 +24,15 @@ if@p1 ((E == NULL && ...) || ...) S1 else S2

// The following two rules are separate, because both can match a single
// expression in different ways
@pr1 depends on !patch expression@
@pr1 expression@
expression *ifm.E;
identifier f;
position p1;
@@

(E != NULL && ...) ? <+...E->f@p1...+> : ...

@pr2 depends on !patch expression@
@pr2 expression@
expression *ifm.E;
identifier f;
position p2;
Expand All @@ -59,7 +48,7 @@ position p2;

// For org and report modes

@r depends on !context && !patch && (org || report) exists@
@r depends on !context && (org || report) exists@
expression subE <= ifm.E;
expression *ifm.E;
expression E1,E2;
Expand Down Expand Up @@ -99,7 +88,7 @@ if@p1 ((E == NULL && ...) || ...)
}
else S3

@script:python depends on !context && !patch && !org && report@
@script:python depends on !context && !org && report@
p << r.p;
p1 << ifm.p1;
x << ifm.E;
Expand All @@ -109,7 +98,7 @@ msg="ERROR: %s is NULL but dereferenced." % (x)
coccilib.report.print_report(p[0], msg)
cocci.include_match(False)
@script:python depends on !context && !patch && org && !report@
@script:python depends on !context && org && !report@
p << r.p;
p1 << ifm.p1;
x << ifm.E;
Expand All @@ -120,7 +109,7 @@ msg_safe=msg.replace("[","@(").replace("]",")")
cocci.print_main(msg_safe,p)
cocci.include_match(False)
@s depends on !context && !patch && (org || report) exists@
@s depends on !context && (org || report) exists@
expression subE <= ifm.E;
expression *ifm.E;
expression E1,E2;
Expand Down Expand Up @@ -159,7 +148,7 @@ if@p1 ((E == NULL && ...) || ...)
}
else S3

@script:python depends on !context && !patch && !org && report@
@script:python depends on !context && !org && report@
p << s.p;
p1 << ifm.p1;
x << ifm.E;
Expand All @@ -168,7 +157,7 @@ x << ifm.E;
msg="ERROR: %s is NULL but dereferenced." % (x)
coccilib.report.print_report(p[0], msg)
@script:python depends on !context && !patch && org && !report@
@script:python depends on !context && org && !report@
p << s.p;
p1 << ifm.p1;
x << ifm.E;
Expand All @@ -180,7 +169,7 @@ cocci.print_main(msg_safe,p)
// For context mode
@depends on context && !patch && !org && !report exists@
@depends on context && !org && !report exists@
expression subE <= ifm.E;
expression *ifm.E;
expression E1,E2;
Expand Down Expand Up @@ -223,23 +212,23 @@ else S3
// The following three rules are duplicates of ifm, pr1 and pr2 respectively.
// It is need because the previous rule as already made a "change".

@ifm1 depends on !patch@
@ifm1@
expression *E;
statement S1,S2;
position p1;
@@

if@p1 ((E == NULL && ...) || ...) S1 else S2

@pr11 depends on !patch expression@
@pr11 expression@
expression *ifm1.E;
identifier f;
position p1;
@@

(E != NULL && ...) ? <+...E->f@p1...+> : ...

@pr12 depends on !patch expression@
@pr12 expression@
expression *ifm1.E;
identifier f;
position p2;
Expand All @@ -253,7 +242,7 @@ position p2;
sizeof(<+...E->f@p2...+>)
)

@depends on context && !patch && !org && !report exists@
@depends on context && !org && !report exists@
expression subE <= ifm1.E;
expression *ifm1.E;
expression E1,E2;
Expand Down

0 comments on commit ad0fd58

Please sign in to comment.