Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf56cc04 authored by Vaishali Thakkar's avatar Vaishali Thakkar Committed by Michal Marek
Browse files

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: default avatarVaishali Thakkar <vaishali.thakkar@oracle.com>
Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarMichal Marek <mmarek@suse.com>
parent 1a695a90
Loading
Loading
Loading
Loading
+17 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@ virtual patch
@depends on patch@
@depends on patch@
expression *x;
expression *x;
expression f;
expression f;
expression i;
type T;
type T;
@@
@@


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


@r depends on !patch@
@r depends on !patch@
expression *x;
expression *x;
expression f;
expression f;
expression i;
position p;
position p;
type T;
type T;
@@
@@
@@ -49,6 +61,10 @@ type T;
*f(...,(T)(x),...,sizeof@p(x),...)
*f(...,(T)(x),...,sizeof@p(x),...)
|
|
*f(...,sizeof@p(x),...,(T)(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@
@script:python depends on org@