From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753344AbcHAL5h (ORCPT ); Mon, 1 Aug 2016 07:57:37 -0400 Received: from mout.web.de ([212.227.15.14]:65201 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753199AbcHAL5b (ORCPT ); Mon, 1 Aug 2016 07:57:31 -0400 Subject: Re: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions To: Julia Lawall , Amitoj Kaur Chawla References: <20160801070233.GA19102@amitoj-Inspiron-3542> Cc: LKML , Coccinelle , Gilles Muller , Michal Marek , Nicolas Palix From: SF Markus Elfring Message-ID: <0dbd2dd6-4c68-1f7c-1500-9e5d40047813@users.sourceforge.net> Date: Mon, 1 Aug 2016 13:56:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:FLSypltZ6e1QbwkaXOsojbD0/IA9LWlOTbpibsWtvNJNbjRDO38 xkaby4WLp+jFvCwvIT7P/T40SaTA+qcuaOpQoxuaKPj4TEHD7swe30Ze1g4dquixVfJ0Nnh IBvtMheJkKQmzHBSZSfELyCPEV1XSbVXUv1UX13x0ZgAoekt2NthOCYL23vnUSdHX3h5qNS RCoA+Jxkp6Zu6GHNpQJng== X-UI-Out-Filterresults: notjunk:1;V01:K0:3WwSuhsw/hM=:NeJhjbCburvmB3a9/IC2Bk ZT2YSgzN+YT6UFtEgiLXZZZukfS6BzYDbQ3+yYs9cJAcH7Fr1ad4O2vF5XnOMy1kFRwlXjFek tCqR0t1GLNv7moqNl/9AZEQrNmbHdYNGs6G6hORh0UzfFh2fauYVWQxYBvzeGAaiRJm5V4Tth 1JHRdfR6zd6L/n7wHj0RF1X4IS+motmNO1pZesEiBI75M3+NNJvp+5p8JzsblXdI1VHmNoOM7 +BXg7WrTCU7qWf0GFrLtavi0AgfDkx/AylOtooVLI3f8VN3Bvm0z95TH3a5fqj4sCODz25o1v s6/h7xjQAaQ1yzRV/vUYzeBB2xkZ7rc2Z6ULT1KaoexpIOKs7UYMqX2hKFQBD8y3ZkQWY0L9C jRtdpAG86iY5T3drNpeXDLkHDcPcxAOgp4DtLAXuFHPfgIBJTwvAhPFUafBfsmKfk/wWA2Hue gs5BstmKPMj1Rq4AN1I1QyWdQ9PZO6QpfVKkdDvXGMz9mB4JKSnT96THxlxXZz+bSBTBZqnwK VOU4dXISlacoQ85Dz5ppeNwYB7PbZHtxkR29poTIrnD3X05aQbB4v+MPnnMPhx+hrEhpw7TAF kvKAV8ewRIrchTf6F8+ivQtwgwiqbVuZXodu5aiDo84pSEpWhWpeeESH0jhcaP8OuoGg9DqjO Ou6uy6bNTLcIJLE0oXaOM/e9fZKZi8tN9JG3eosQvvFxeR0xdbBy83PaNgtnD5J4OAdMHhGSq uNj/bIs1XfS4b61I2usX4b6e9/p8+I+Z4PvMez+Q95cT/LgpgxsFJAqZ0f3UHVgmFFiT0cMvN VHsaKwi Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> 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) ) -)); > 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: elfring@users.sourceforge.net (SF Markus Elfring) Date: Mon, 1 Aug 2016 13:56:58 +0200 Subject: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions In-Reply-To: References: <20160801070233.GA19102@amitoj-Inspiron-3542> Message-ID: <0dbd2dd6-4c68-1f7c-1500-9e5d40047813@users.sourceforge.net> To: cocci@systeme.lip6.fr List-Id: cocci@systeme.lip6.fr >> 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) ) -)); > Perhaps in performance as well. I admit that I am unsure about the run-time characteristics for my suggestion. Regards, Markus