linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] Coccinelle: noderef: Add new rules and correct the old rule
@ 2016-05-24  4:19 Vaishali Thakkar
  2016-05-24  8:39 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Vaishali Thakkar @ 2016-05-24  4:19 UTC (permalink / raw)
  To: Julia.Lawall
  Cc: Gilles.Muller, nicolas.palix, mmarek, cocci, linux-kernel,
	Vaishali Thakkar

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>
---
Changes since v2:
	- Add rules for function calls. This will behave as
          more general rules and covers cases which were
          covered by the rule in previous versions of the patch
	- Change subject and commit log accordingly.
Changes since v1:
	- Declare i as an expression instead of identifier to
	  cover more cases
---
 scripts/coccinelle/misc/noderef.cocci | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci
index 80a831c..007f0de 100644
--- a/scripts/coccinelle/misc/noderef.cocci
+++ b/scripts/coccinelle/misc/noderef.cocci
@@ -16,6 +16,7 @@ virtual patch
 @depends on patch@
 expression *x;
 expression f;
+expression i;
 type T;
 @@
 
@@ -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;
 @@
@@ -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@
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] Coccinelle: noderef: Add new rules and correct the old rule
  2016-05-24  4:19 [PATCH v3] Coccinelle: noderef: Add new rules and correct the old rule Vaishali Thakkar
@ 2016-05-24  8:39 ` Julia Lawall
  2016-06-20 15:20   ` Michal Marek
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2016-05-24  8:39 UTC (permalink / raw)
  To: Vaishali Thakkar
  Cc: Gilles Muller, nicolas.palix, mmarek, cocci, linux-kernel

Acked-by: Julia Lawall <julia.lawall@lip6.fr>

On Tue, 24 May 2016, Vaishali Thakkar wrote:

> 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>
> ---
> Changes since v2:
> 	- Add rules for function calls. This will behave as
>           more general rules and covers cases which were
>           covered by the rule in previous versions of the patch
> 	- Change subject and commit log accordingly.
> Changes since v1:
> 	- Declare i as an expression instead of identifier to
> 	  cover more cases
> ---
>  scripts/coccinelle/misc/noderef.cocci | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci
> index 80a831c..007f0de 100644
> --- a/scripts/coccinelle/misc/noderef.cocci
> +++ b/scripts/coccinelle/misc/noderef.cocci
> @@ -16,6 +16,7 @@ virtual patch
>  @depends on patch@
>  expression *x;
>  expression f;
> +expression i;
>  type T;
>  @@
>
> @@ -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;
>  @@
> @@ -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@
> --
> 2.1.4
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] Coccinelle: noderef: Add new rules and correct the old rule
  2016-05-24  8:39 ` Julia Lawall
@ 2016-06-20 15:20   ` Michal Marek
  0 siblings, 0 replies; 3+ messages in thread
From: Michal Marek @ 2016-06-20 15:20 UTC (permalink / raw)
  To: Julia Lawall, Vaishali Thakkar
  Cc: Gilles Muller, nicolas.palix, cocci, linux-kernel

On 2016-05-24 10:39, Julia Lawall wrote:
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> 
> On Tue, 24 May 2016, Vaishali Thakkar wrote:
> 
>> 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>

Applied to kbuild.git#misc.

Michal

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-20 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-24  4:19 [PATCH v3] Coccinelle: noderef: Add new rules and correct the old rule Vaishali Thakkar
2016-05-24  8:39 ` Julia Lawall
2016-06-20 15:20   ` Michal Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).