From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753458AbcHAMDg (ORCPT ); Mon, 1 Aug 2016 08:03:36 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:35400 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753338AbcHAMD1 (ORCPT ); Mon, 1 Aug 2016 08:03:27 -0400 X-IronPort-AV: E=Sophos;i="5.28,454,1464645600"; d="scan'208";a="186556455" Date: Mon, 1 Aug 2016 14:03:25 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: SF Markus Elfring cc: Amitoj Kaur Chawla , LKML , Coccinelle , Gilles Muller , Michal Marek , Nicolas Palix Subject: Re: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions In-Reply-To: <0dbd2dd6-4c68-1f7c-1500-9e5d40047813@users.sourceforge.net> Message-ID: References: <20160801070233.GA19102@amitoj-Inspiron-3542> <0dbd2dd6-4c68-1f7c-1500-9e5d40047813@users.sourceforge.net> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 1 Aug 2016, SF Markus Elfring wrote: > >> 1. Would it make sense to merge such SmPL rules into one > >> so that code duplication could be reduced a bit > >> in such a script? > > > > I think it would suffer in readability. > > How do you think about the following SmPL script example? > > @vz_combined > depends on patch && !context && !org && !report@ > type T; > T* pointer; > +statement S; > expression express; > @@ > pointer = > - vmalloc > + vzalloc > (...); > if (!d) > S > -memset(d, 0, sizeof( > ( > -T > | > -*(express) > ) > -)); OK, I thought you meant to make a big disjunctions for all of the before and after functions. This is a little better because it is bounded in size. But I don't understand why you have introduced the variable express. Normally one wants the cleared space to be the allocated size, which is normally the size of *pointer. The performance issue is that disjunctions on expressions, eg (A | B), are implemented as (A | (!A & B)), ie with a negation of all the previous options &d with each option. So it is better to avoid very large disjunctions on expressions. julia > > > > Perhaps in performance as well. > > I admit that I am unsure about the run-time characteristics > for my suggestion. > > Regards, > Markus > From mboxrd@z Thu Jan 1 00:00:00 1970 From: julia.lawall@lip6.fr (Julia Lawall) Date: Mon, 1 Aug 2016 14:03:25 +0200 (CEST) Subject: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions In-Reply-To: <0dbd2dd6-4c68-1f7c-1500-9e5d40047813@users.sourceforge.net> References: <20160801070233.GA19102@amitoj-Inspiron-3542> <0dbd2dd6-4c68-1f7c-1500-9e5d40047813@users.sourceforge.net> Message-ID: To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr On Mon, 1 Aug 2016, SF Markus Elfring wrote: > >> 1. Would it make sense to merge such SmPL rules into one > >> so that code duplication could be reduced a bit > >> in such a script? > > > > I think it would suffer in readability. > > How do you think about the following SmPL script example? > > @vz_combined > depends on patch && !context && !org && !report@ > type T; > T* pointer; > +statement S; > expression express; > @@ > pointer = > - vmalloc > + vzalloc > (...); > if (!d) > S > -memset(d, 0, sizeof( > ( > -T > | > -*(express) > ) > -)); OK, I thought you meant to make a big disjunctions for all of the before and after functions. This is a little better because it is bounded in size. But I don't understand why you have introduced the variable express. Normally one wants the cleared space to be the allocated size, which is normally the size of *pointer. The performance issue is that disjunctions on expressions, eg (A | B), are implemented as (A | (!A & B)), ie with a negation of all the previous options &d with each option. So it is better to avoid very large disjunctions on expressions. julia > > > > Perhaps in performance as well. > > I admit that I am unsure about the run-time characteristics > for my suggestion. > > Regards, > Markus >