Skip to content

Commit

Permalink
Coccinelle: noderef: Add new rules and correct the old rule
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vaishali Thakkar authored and Michal Marek committed Jun 20, 2016
1 parent 1a695a9 commit bf56cc0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion scripts/coccinelle/misc/noderef.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ virtual patch
@depends on patch@
expression *x;
expression f;
expression i;
type T;
@@

Expand All @@ -30,15 +31,26 @@ f(...,(T)(x),...,sizeof(
+ *x
),...)
|
f(...,sizeof(x),...,(T)(
f(...,sizeof(
- x
+ *x
),...,(T)(x),...)
|
f(...,(T)(x),...,i*sizeof(
- x
+ *x
),...)
|
f(...,i*sizeof(
- x
+ *x
),...,(T)(x),...)
)

@r depends on !patch@
expression *x;
expression f;
expression i;
position p;
type T;
@@
Expand All @@ -49,6 +61,10 @@ type T;
*f(...,(T)(x),...,sizeof@p(x),...)
|
*f(...,sizeof@p(x),...,(T)(x),...)
|
*f(...,(T)(x),...,i*sizeof@p(x),...)
|
*f(...,i*sizeof@p(x),...,(T)(x),...)
)

@script:python depends on org@
Expand Down

0 comments on commit bf56cc0

Please sign in to comment.