Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3393426pxj; Mon, 14 Jun 2021 23:14:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTm/xxYrv8vlFGrLnxKG62QoDadu46V6UtK6ClNmaMemyPdBiJx3EJe75WV2Kwb/m0+FIP X-Received: by 2002:a05:6402:2378:: with SMTP id a24mr21127257eda.161.1623737690260; Mon, 14 Jun 2021 23:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623737690; cv=none; d=google.com; s=arc-20160816; b=QrwghStTH9q+A1BYg42u7OAOglcX7QhI4qoXhWU8i/+KcIn2AlhCTsaTw5pJ5EkD/0 GFD99W8DSYYXEXHWgdoyUZg8SnHyzG7uF32/abnWjLyeqJ+EyTdUYx4/jt4Q+1kO1gSP unR2RJvCbAz3bE03m6ahcMxl1StnlDlmYWekw7LbJgbgyRppPo2leHjeK5rBWuZR4d7v 6MSdJbvLgAWZOhjFhiDnEArOlsfhW6v8aq1fqLaEowfHX4E+EHrviAk1zTYWo1ZLSPxM d7+JDOXxSP1lBrZ2C3kuq3+S8PojujdiOyMTRV9NEo0ZIecAXG5biYh83Z0NjmvSihA5 mPsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=/Qpjst8fUK2jK/roldcWP3QnKsbToK1R2ztKok4xwGQ=; b=uxjAA7Q6VAdgQOEYcRGYxpq7isRP/jAvgcOMOuzRKbqqA3C9mby0LyoGslJ6Bnsigl 6inQVSIeDvRhcgbXMcw38d9qH+RoPqqYg1nFNzeTLk5v/77xT/p0M2uFmoZqyU/EzUhB AS4S20jf7n0tnnbNYgQJNsVsE4kOKGW67xNTHlVRAiqUZ2ZBhF3fu+j+ZPGOLT24xzY2 IqfMupbgjWt/isMwmeEy2jdI3HTeHm0kr8bWSZRvP6wCF+ib4TPqiy8+hZX7m5t7yEQ/ XkvBl3//0mMWfQreeDGsF5fABKu5VcFiCCotLSnvWE5ZaZqXCYhul+T82YVyPr9eKdeY 2T5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w19si13014507edc.458.2021.06.14.23.14.27; Mon, 14 Jun 2021 23:14:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbhFOGPc (ORCPT + 99 others); Tue, 15 Jun 2021 02:15:32 -0400 Received: from mail-lj1-f182.google.com ([209.85.208.182]:37408 "EHLO mail-lj1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbhFOGP3 (ORCPT ); Tue, 15 Jun 2021 02:15:29 -0400 Received: by mail-lj1-f182.google.com with SMTP id k8so6465914lja.4 for ; Mon, 14 Jun 2021 23:13:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/Qpjst8fUK2jK/roldcWP3QnKsbToK1R2ztKok4xwGQ=; b=FO7OyLBUqH9lVESxRW/FhgL+Bzro1rII7fOPt6HBd43A1JAmnAPYGDgO1GuvvatCpg 1/xoUNV1rVZfjcqEerMYcZUgNAqUiMeyZuz97Kuhjao1HC5ozkBXMTIGR07Hxx9SONE5 //7KOACDA+bpgyKJnXd/Uy96NTOE+v/PWygxbGHVifQAehWPh98aZXmUn3du3Clhik8C /fATFJ/Xtnb7CrIafQ3NRQc0JTckau0Bhyx2wVXsp0E5Jl6o8RqhSFWKst9evynLrON8 3XF21CVuXLbZBg0g4sJ7ObrnaWr7tnbPCJefj027brgRT50rI+Lsu4JQfUVwe4H5Xa4Y 2pmw== X-Gm-Message-State: AOAM533Ti713L6asz87K7XQe46BdBBNDUvoh52MNPZGM8cGch4MT2acJ Y4xC5WQ2lBIqQ3fqHe+ZUw34I1vbcvM= X-Received: by 2002:a05:651c:1202:: with SMTP id i2mr16183629lja.323.1623737603819; Mon, 14 Jun 2021 23:13:23 -0700 (PDT) Received: from [10.68.32.192] (broadband-188-32-236-56.ip.moscow.rt.ru. [188.32.236.56]) by smtp.gmail.com with ESMTPSA id h12sm2049998ljg.59.2021.06.14.23.13.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Jun 2021 23:13:23 -0700 (PDT) Subject: Re: [RESEND PATCH] coccinelle: misc: minmax: suppress patch generation for err returns To: Julia Lawall Cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org References: <20210428060350.57661-1-efremov@linux.com> From: Denis Efremov Message-ID: <6296d731-60d3-1ceb-226d-ded9d2d5a1f9@linux.com> Date: Tue, 15 Jun 2021 09:13:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210428060350.57661-1-efremov@linux.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ping? On 4/28/21 9:03 AM, Denis Efremov wrote: > There is a standard idiom for "if 'ret' holds an error, return it": > return ret < 0 ? ret : 0; > > Developers prefer to keep the things as they are because stylistic > change to "return min(ret, 0);" breaks readability. > > Let's suppress automatic generation for this type of patches. > > Signed-off-by: Denis Efremov > --- > scripts/coccinelle/misc/minmax.cocci | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > diff --git a/scripts/coccinelle/misc/minmax.cocci b/scripts/coccinelle/misc/minmax.cocci > index eccdd3eb3452..fcf908b34f27 100644 > --- a/scripts/coccinelle/misc/minmax.cocci > +++ b/scripts/coccinelle/misc/minmax.cocci > @@ -116,16 +116,32 @@ func(...) > ...> > } > > +// Don't generate patches for errcode returns. > +@errcode depends on patch@ > +position p; > +identifier func; > +expression x; > +binary operator cmp = {<, <=}; > +@@ > + > +func(...) > +{ > + <... > + return ((x) cmp@p 0 ? (x) : 0); > + ...> > +} > + > @pmin depends on patch@ > identifier func; > expression x, y; > binary operator cmp = {<=, <}; > +position p != errcode.p; > @@ > > func(...) > { > <... > -- ((x) cmp (y) ? (x) : (y)) > +- ((x) cmp@p (y) ? (x) : (y)) > + min(x, y) > ...> > } >