From: Vaishali Thakkar Date: Tue, 24 May 2016 04:19:17 +0000 (+0530) Subject: UPSTREAM: Coccinelle: noderef: Add new rules and correct the old rule X-Git-Tag: release-20171130_firefly~4^2~218 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=24b3eaac3a58df83dde048310994b4570d5ea3d8;p=firefly-linux-kernel-4.4.55.git UPSTREAM: 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. Change-Id: Id50b413c43d1c7f8c17a8cd784aa4d9d90046e62 Signed-off-by: Vaishali Thakkar Acked-by: Julia Lawall Signed-off-by: Michal Marek Signed-off-by: Huang, Tao (cherry picked from commit bf56cc04ef97c8ec536e3fcd16fc57902cba339f) --- diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci index 80a831c91161..007f0de0c715 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@