diff options
author | Vaishali Thakkar <vaishali.thakkar@oracle.com> | 2016-05-24 00:19:17 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.com> | 2016-06-20 11:20:13 -0400 |
commit | bf56cc04ef97c8ec536e3fcd16fc57902cba339f (patch) | |
tree | 0e45c354d1a4b294f001ee876086196ca6b201da | |
parent | 1a695a905c18548062509178b98bc91e67510864 (diff) |
Coccinelle: noderef: Add new rules and correct the old rule
Add new rules to detect the cases where sizeof is used in
function calls as a argument.
Also, for the patch mode third rule should behave same as
second rule with arguments reversed. So, change that as well.
Signed-off-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
-rw-r--r-- | scripts/coccinelle/misc/noderef.cocci | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci index 80a831c91161..007f0de0c715 100644 --- a/scripts/coccinelle/misc/noderef.cocci +++ b/scripts/coccinelle/misc/noderef.cocci | |||
@@ -16,6 +16,7 @@ virtual patch | |||
16 | @depends on patch@ | 16 | @depends on patch@ |
17 | expression *x; | 17 | expression *x; |
18 | expression f; | 18 | expression f; |
19 | expression i; | ||
19 | type T; | 20 | type T; |
20 | @@ | 21 | @@ |
21 | 22 | ||
@@ -30,15 +31,26 @@ f(...,(T)(x),...,sizeof( | |||
30 | + *x | 31 | + *x |
31 | ),...) | 32 | ),...) |
32 | | | 33 | | |
33 | f(...,sizeof(x),...,(T)( | 34 | f(...,sizeof( |
35 | - x | ||
36 | + *x | ||
37 | ),...,(T)(x),...) | ||
38 | | | ||
39 | f(...,(T)(x),...,i*sizeof( | ||
34 | - x | 40 | - x |
35 | + *x | 41 | + *x |
36 | ),...) | 42 | ),...) |
43 | | | ||
44 | f(...,i*sizeof( | ||
45 | - x | ||
46 | + *x | ||
47 | ),...,(T)(x),...) | ||
37 | ) | 48 | ) |
38 | 49 | ||
39 | @r depends on !patch@ | 50 | @r depends on !patch@ |
40 | expression *x; | 51 | expression *x; |
41 | expression f; | 52 | expression f; |
53 | expression i; | ||
42 | position p; | 54 | position p; |
43 | type T; | 55 | type T; |
44 | @@ | 56 | @@ |
@@ -49,6 +61,10 @@ type T; | |||
49 | *f(...,(T)(x),...,sizeof@p(x),...) | 61 | *f(...,(T)(x),...,sizeof@p(x),...) |
50 | | | 62 | | |
51 | *f(...,sizeof@p(x),...,(T)(x),...) | 63 | *f(...,sizeof@p(x),...,(T)(x),...) |
64 | | | ||
65 | *f(...,(T)(x),...,i*sizeof@p(x),...) | ||
66 | | | ||
67 | *f(...,i*sizeof@p(x),...,(T)(x),...) | ||
52 | ) | 68 | ) |
53 | 69 | ||
54 | @script:python depends on org@ | 70 | @script:python depends on org@ |