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

Unified · Split

scripts/coccinelle/misc/noderef.cocci+17−1
@@ -16,6 +16,7 @@ virtual patch · 15 unmodified lines
1616 @depends on patch@
1717 expression *x;
1818 expression f;
19+expression i;
1920 type T;
2021 @@
2122
@@ -30,15 +31,26 @@ f(...,(T)(x),...,sizeof( · 8 unmodified lines
3031 + *x
3132 ),...)
3233 |
33−f(...,sizeof(x),...,(T)(
34+f(...,sizeof(
35+- x
36++ *x
37+ ),...,(T)(x),...)
38+|
39+f(...,(T)(x),...,i*sizeof(
3440 - x
3541 + *x
3642 ),...)
43+|
44+f(...,i*sizeof(
45+- x
46++ *x
47+ ),...,(T)(x),...)
3748 )
3849
3950 @r depends on !patch@
4051 expression *x;
4152 expression f;
53+expression i;
4254 position p;
4355 type T;
4456 @@
@@ -49,6 +61,10 @@ type T; · 4 unmodified lines
4961 *f(...,(T)(x),...,sizeof@p(x),...)
5062 |
5163 *f(...,sizeof@p(x),...,(T)(x),...)
64+|
65+*f(...,(T)(x),...,i*sizeof@p(x),...)
66+|
67+*f(...,i*sizeof@p(x),...,(T)(x),...)
5268 )
5369
5470 @script:python depends on org@