From mboxrd@z Thu Jan 1 00:00:00 1970 From: Liam Breck Subject: Re: [PATCH v3 0/5] bq27xxx_battery data memory update Date: Tue, 19 Sep 2017 15:36:28 -0700 Message-ID: References: <20170824033617.20840-1-liam@networkimprov.net> <20170829105413.6wbejdaxxxd6hk7b@earth> <0bf4ba2f-18f9-1204-8241-8acb6ac6f490@ti.com> <20170829212259.gs4bljwscrprsfjl@earth> <20170830002939.ns43wldvffmwqhuv@earth> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from mail-it0-f66.google.com ([209.85.214.66]:33738 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751520AbdISWga (ORCPT ); Tue, 19 Sep 2017 18:36:30 -0400 Received: by mail-it0-f66.google.com with SMTP id g18so558817itg.0 for ; Tue, 19 Sep 2017 15:36:30 -0700 (PDT) In-Reply-To: Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org To: Julia Lawall Cc: Sebastian Reichel , Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, "Andrew F. Davis" , =?UTF-8?Q?Pali_Roh=C3=A1r?= , Linux PM mailing list On Tue, Sep 19, 2017 at 3:00 PM, Julia Lawall wrote: > > > On Tue, 19 Sep 2017, Liam Breck wrote: > >> Hi Julia, >> >> I think Sebastian referred this to you in hopes of receiving a script >> that would find duplicate arrays, similarly to the way >> bq27xxx_battery_dbg_dupes does in the running code. Did you interpret >> his request differently? >> >> bq27xxx_battery_dbg_dupes: >> https://patchwork.kernel.org/patch/9918953/ >> >> The data structures being checked start here: >> https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/tree/drivers/power/supply/bq27xxx_battery.c?h=for-next#n138 >> >> And are aggregated here: >> https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/tree/drivers/power/supply/bq27xxx_battery.c?h=for-next#n743 >> >> The defines can be sed'd to pointers with 0 value, and array >> comparisons where 1 pointer is 0 can be skipped. > > I followed the spirit of the runtime testing code. But Coccinelle doesn't > normally unfold the definitions of macros. All it can do is take the > different lists of fields and see if they are textually the same. There's no need to unfold macros. If you did, you would get false positives. You do need to skip them somehow, hence the idea of sed'ing to null pointers. > I've attached the script and some fake data that I made to test it. The > fake data has some added cases where I have replaced 27 in the structure > name by 07. For my test data I get: > > bq07421_regs and bq27421_regs have the same registers > bq07000_regs and bq27000_regs have the same registers > bq07421_dm_regs and bq27421_dm_regs have the same registers > bq07421_props and bq27421_props have the same properties > bq07000_props and bq27000_props have the same properties > > You won't get this currently; I needed to make some improvements to the > Coccinelle C code parser. I didn't see anything attached, script or data. The script should compare each object with only those objects that follow it in sequence, so it doesn't repeat comparisons or compare to self. From mboxrd@z Thu Jan 1 00:00:00 1970 From: liam@networkimprov.net (Liam Breck) Date: Tue, 19 Sep 2017 15:36:28 -0700 Subject: [Cocci] [PATCH v3 0/5] bq27xxx_battery data memory update In-Reply-To: References: <20170824033617.20840-1-liam@networkimprov.net> <20170829105413.6wbejdaxxxd6hk7b@earth> <0bf4ba2f-18f9-1204-8241-8acb6ac6f490@ti.com> <20170829212259.gs4bljwscrprsfjl@earth> <20170830002939.ns43wldvffmwqhuv@earth> Message-ID: To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr On Tue, Sep 19, 2017 at 3:00 PM, Julia Lawall wrote: > > > On Tue, 19 Sep 2017, Liam Breck wrote: > >> Hi Julia, >> >> I think Sebastian referred this to you in hopes of receiving a script >> that would find duplicate arrays, similarly to the way >> bq27xxx_battery_dbg_dupes does in the running code. Did you interpret >> his request differently? >> >> bq27xxx_battery_dbg_dupes: >> https://patchwork.kernel.org/patch/9918953/ >> >> The data structures being checked start here: >> https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/tree/drivers/power/supply/bq27xxx_battery.c?h=for-next#n138 >> >> And are aggregated here: >> https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/tree/drivers/power/supply/bq27xxx_battery.c?h=for-next#n743 >> >> The defines can be sed'd to pointers with 0 value, and array >> comparisons where 1 pointer is 0 can be skipped. > > I followed the spirit of the runtime testing code. But Coccinelle doesn't > normally unfold the definitions of macros. All it can do is take the > different lists of fields and see if they are textually the same. There's no need to unfold macros. If you did, you would get false positives. You do need to skip them somehow, hence the idea of sed'ing to null pointers. > I've attached the script and some fake data that I made to test it. The > fake data has some added cases where I have replaced 27 in the structure > name by 07. For my test data I get: > > bq07421_regs and bq27421_regs have the same registers > bq07000_regs and bq27000_regs have the same registers > bq07421_dm_regs and bq27421_dm_regs have the same registers > bq07421_props and bq27421_props have the same properties > bq07000_props and bq27000_props have the same properties > > You won't get this currently; I needed to make some improvements to the > Coccinelle C code parser. I didn't see anything attached, script or data. The script should compare each object with only those objects that follow it in sequence, so it doesn't repeat comparisons or compare to self.