From mboxrd@z Thu Jan 1 00:00:00 1970 From: vaishali.thakkar@oracle.com (Vaishali Thakkar) Date: Fri, 6 May 2016 10:17:48 +0530 Subject: [Cocci] [PATCH] Coccinelle: noderef: Add a rule and correct the old rule In-Reply-To: References: <1461757289-21035-1-git-send-email-vaishali.thakkar@oracle.com> Message-ID: <572C21F4.9060607@oracle.com> To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr On Friday 06 May 2016 01:40 AM, Julia Lawall wrote: > > > On Wed, 27 Apr 2016, Vaishali Thakkar wrote: > >> Add a new rule to detect the cases where sizeof is used as a >> subexpression rather than a top level 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 >> --- >> scripts/coccinelle/misc/noderef.cocci | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci >> index 80a831c..9991ee9 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; >> +identifier i; > > I think that i could be an expression in both cases? Yeah, that would be fine I guess. I'll send the v2. > julia > >> type T; >> @@ >> >> @@ -30,7 +31,12 @@ f(...,(T)(x),...,sizeof( >> + *x >> ),...) >> | >> -f(...,sizeof(x),...,(T)( >> +f(...,sizeof( >> +- x >> ++ *x >> + ),...,(T)(x),...) >> +| >> +x = f(...,i*sizeof( >> - x >> + *x >> ),...) >> @@ -39,6 +45,7 @@ f(...,sizeof(x),...,(T)( >> @r depends on !patch@ >> expression *x; >> expression f; >> +identifier i; >> position p; >> type T; >> @@ >> @@ -49,6 +56,8 @@ type T; >> *f(...,(T)(x),...,sizeof at p(x),...) >> | >> *f(...,sizeof at p(x),...,(T)(x),...) >> +| >> +*x = f(...,i*sizeof at p(x),...) >> ) >> >> @script:python depends on org@ >> -- >> 2.1.4 >> >> -- Vaishali From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751678AbcEFEsS (ORCPT ); Fri, 6 May 2016 00:48:18 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:42312 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750860AbcEFEsR (ORCPT ); Fri, 6 May 2016 00:48:17 -0400 Subject: Re: [PATCH] Coccinelle: noderef: Add a rule and correct the old rule To: Julia Lawall References: <1461757289-21035-1-git-send-email-vaishali.thakkar@oracle.com> Cc: Gilles Muller , nicolas.palix@imag.fr, mmarek@suse.com, cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org From: Vaishali Thakkar Message-ID: <572C21F4.9060607@oracle.com> Date: Fri, 6 May 2016 10:17:48 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 06 May 2016 01:40 AM, Julia Lawall wrote: > > > On Wed, 27 Apr 2016, Vaishali Thakkar wrote: > >> Add a new rule to detect the cases where sizeof is used as a >> subexpression rather than a top level 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 >> --- >> scripts/coccinelle/misc/noderef.cocci | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci >> index 80a831c..9991ee9 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; >> +identifier i; > > I think that i could be an expression in both cases? Yeah, that would be fine I guess. I'll send the v2. > julia > >> type T; >> @@ >> >> @@ -30,7 +31,12 @@ f(...,(T)(x),...,sizeof( >> + *x >> ),...) >> | >> -f(...,sizeof(x),...,(T)( >> +f(...,sizeof( >> +- x >> ++ *x >> + ),...,(T)(x),...) >> +| >> +x = f(...,i*sizeof( >> - x >> + *x >> ),...) >> @@ -39,6 +45,7 @@ f(...,sizeof(x),...,(T)( >> @r depends on !patch@ >> expression *x; >> expression f; >> +identifier i; >> position p; >> type T; >> @@ >> @@ -49,6 +56,8 @@ type T; >> *f(...,(T)(x),...,sizeof@p(x),...) >> | >> *f(...,sizeof@p(x),...,(T)(x),...) >> +| >> +*x = f(...,i*sizeof@p(x),...) >> ) >> >> @script:python depends on org@ >> -- >> 2.1.4 >> >> -- Vaishali