From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753763AbcHAM1w (ORCPT ); Mon, 1 Aug 2016 08:27:52 -0400 Received: from mout.web.de ([212.227.17.12]:53427 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753541AbcHAMZG (ORCPT ); Mon, 1 Aug 2016 08:25:06 -0400 Subject: Re: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions To: Julia Lawall References: <20160801070233.GA19102@amitoj-Inspiron-3542> <0dbd2dd6-4c68-1f7c-1500-9e5d40047813@users.sourceforge.net> Cc: Amitoj Kaur Chawla , LKML , Coccinelle , Gilles Muller , Michal Marek , Nicolas Palix From: SF Markus Elfring Message-ID: Date: Mon, 1 Aug 2016 14:24:53 +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: 8bit X-Provags-ID: V03:K0:dYpuDyISWGGuzBLw46HuJgG9qbUIwfXYmeYoJOOrcA4EgH693l6 yiiJ+5uKwvmNvLy6Kkwze6L0xMxzdwJWJaMSLNpju5QzYTUQPcAdEMFC71EiodhA4NbSZ7g 5Vn/M38MFM/3RWOgXMHg8oSIYUFMwy96jYt9eh+oavd3LhUN9ZWFMu3OVhPo4ZuXRffehj9 NsjAiFMrLKSqSJ7n6JWqA== X-UI-Out-Filterresults: notjunk:1;V01:K0:ekuoGUIAf2g=:FBCEccXp5hikgOQGc5htOM ycv9AdbwfTfj35HOLhzaMuaO+OnQiR33eahEcCpDA7fRtmeGS9PAZQdPkg/fktsQe3RKUKYH6 itu+uS16WbBpSNXLqDvqdYN7kI5Jyig7+ZDAEHTObO3Hp98xRq3ZixQrNhandKLDXdKepHJaS kqHAy9/momR13OwyvQGF6XMTxt/q/KJB0LhqvUmmvsPfvwsUE+UN5n7jYoUGNugoJZLbY+dP6 1c2CwddIfMer3ZifFsiQhePChUXcMaU6NFPkhwX4e3pC9UZGgU5/XCzNH4CKey4bZFdeamjOG crm5v95meauhAt8RtCNiKYISY6wnjntH7caBz2j3lmK4cJJ3KydcA5kxfTxA9DlRqpp5/Wk72 BPwEUV0uGpUj/0fuqBjlABFhwooSxCrOEudVaW3lCtKPxTnJEjAPgQ5NLzz6OALxRhkNDOJTy 11+radV+PXoZRjKp4qIj5I9+mRCjVQSB+eoHurToVBmR+oZCUp/CjLMAyZIOCDz/CcbBAg2Ay QjvklAVvjCrJkRzQeXSy3cYixhU2Ln+1UodO4D32ZtjBWaO3Q1XR1AKYZ+Mf8D8erD/W9SNm7 gvTF0Y+7CfHGqCfoR3au9E/IdF+vC/q8CnyJVm/mQdB9zVCVxpXn25Q/kh3aokf54HhXjlTtJ IAbNHfcLBPGIp+4zq0Qpa2LiZn+e6smviMjQlJY1PIUv5oS6MOZHp7crCOfj9+2aeWqaFCfeC KrHBnF4V35VWfyze33RS3Rrh460UqP1TbbWE58/rE99l4vAYHTREPdW/7CpaC0F7Wf1V16hs+ aWiTjpr Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> 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. I imagine that it would be nice if the function name pairs could be specified in a more succinct format for the semantic patch language. But the discussed approach can work with a recent software version already. > This is a little better because it is bounded in size. Thanks … > But I don't understand why you have introduced the variable express. I have noticed that these two SmPL rules differed only in the source code search specification for the operator "sizeof". So I would prefer to express this small difference in the script directly. > 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. Is the suggested SmPL disjunction still small enough for this concern? Regards, Markus