History

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.

Vaishali Thakkar committed 10 years ago

Commit bf56cc01 parent 1a695a91 file · +17 −1Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/coccinelle/misc/noderef.cocci+17−1
@@ -16,6 +16,7 @@ virtual patch · 15 unmodified lines
16@depends on patch@16@depends on patch@
17expression *x;17expression *x;
18expression f;18expression f;
19expression i;
19type T;20type T;
20@@21@@
21 22
@@ -30,15 +31,26 @@ f(...,(T)(x),...,sizeof( · 8 unmodified lines
30+ *x31+ *x
31 ),...)32 ),...)
32|33|
33f(...,sizeof(x),...,(T)(34f(...,sizeof(
35- x
36+ *x
37 ),...,(T)(x),...)
38|
39f(...,(T)(x),...,i*sizeof(
34- x40- x
35+ *x41+ *x
36 ),...)42 ),...)
43|
44f(...,i*sizeof(
45- x
46+ *x
47 ),...,(T)(x),...)
37)48)
38 49
39@r depends on !patch@50@r depends on !patch@
40expression *x;51expression *x;
41expression f;52expression f;
53expression i;
42position p;54position p;
43type T;55type T;
44@@56@@
@@ -49,6 +61,10 @@ type T; · 4 unmodified lines
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@