Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp59919ybl; Tue, 7 Jan 2020 02:08:19 -0800 (PST) X-Google-Smtp-Source: APXvYqw2b4yeDBrwRzEk5cKM4quVBqoj4D0sO7nmPJEIscoy47qejQgorxcIbjpqppcUhPMjMiyc X-Received: by 2002:a05:6830:13d3:: with SMTP id e19mr112752337otq.135.1578391699464; Tue, 07 Jan 2020 02:08:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578391699; cv=none; d=google.com; s=arc-20160816; b=eyB7HLIJRT463b/BAdN8F9c0Qv1bA5A/n/GnTLw7RT9du9Jn+o8NDAa1Xo5Zf6WC5E 1QCCQO1fDdrMo5fJf7qnaZwwCqME/sfWEIO5OL4S5zma8jTNftsGo9TJHGlcxxxYqw3p 4XArHDLbmaKRf1vwnColVZczbMeVl9+ahtP9ttbUxhzdFGgHzoLUAdOfUeBoXDKrKABk ZbAF61KQdobmHbZ0mBhJe7Xxd0hyONJxIUNQBIEs7jIlB2GFG52AjaMUXbJg5EtX1RaG qbadplFEFbEZcYNAQ3ZkQSr/Hq/QZ3MX49kg1feD5ldCwxuBix4St/pZG5sXD1z2gX/m AczA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=F1g53S6AqieO3vf3MAVjj+cOHkv+c7jWphf60vr1W3o=; b=vwsncahaqHKvUJzHNvV3dI8q4dx1ng/H7b8I6v+iGxiGFjn+9ylVksrEsuwV1VqozH /psqhRwdUfXvnNSanOQ1tdqT9QGVhMRNMJUEm56TIclaHk7jbt2AI9zqM4R5D38IlkdC Jue8JFDYFeFfqUhJkYgciC2RwAlFs79XvQ8oc7ieshlQJoHDo8BviM87I/viRTxFzOvL OFjA3NrsWzMTzz/nR2jTrUJrAqtXbdfuBN4zI+XM8tygRCYpHC5fXB3ztMylmTaSFMKy nYHdHnyM8pytx0Dgte1VXy5sJspjGlMMHJz7A0Kczm9WxwYiOHsB7oOWGFBXmZnvZ3ZO yB6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si36908027ota.19.2020.01.07.02.08.05; Tue, 07 Jan 2020 02:08:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727753AbgAGKHB (ORCPT + 99 others); Tue, 7 Jan 2020 05:07:01 -0500 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:28978 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbgAGKHB (ORCPT ); Tue, 7 Jan 2020 05:07:01 -0500 X-IronPort-AV: E=Sophos;i="5.69,405,1571695200"; d="scan'208";a="430190722" Received: from dt-lawall.paris.inria.fr ([128.93.67.65]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2020 11:06:56 +0100 Date: Tue, 7 Jan 2020 11:06:56 +0100 (CET) From: Julia Lawall X-X-Sender: julia@hadrien To: Maxime Ripard cc: Julia.Lawall@lip6.fr, Gilles.Muller@lip6.fr, nicolas.palix@imag.fr, michal.lkml@markovi.net, cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, Jani Nikula , Thierry Reding , Tomi Valkeinen , Mark Brown Subject: Re: [PATCH] coccinnelle: Remove ptr_ret script In-Reply-To: <20200107073629.325249-1-maxime@cerno.tech> Message-ID: References: <20200107073629.325249-1-maxime@cerno.tech> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 7 Jan 2020, Maxime Ripard wrote: > The ptr_ret script script addresses a number of situations where we end up > testing an error pointer, and if it's an error returning it, or return 0 > otherwise to transform it into a PTR_ERR_OR_ZERO call. > > So it will convert a block like this: > > if (IS_ERR(err)) > return PTR_ERR(err); > > return 0; > > into > > return PTR_ERR_OR_ZERO(err); > > While this is technically correct, it has a number of drawbacks. First, it > merges the error and success path, which will make it harder for a reviewer > or reader to grasp. > > It's also more difficult to extend if we were to add some code between the > error check and the function return, making the author essentially revert > that patch before adding new lines, while it would have been a trivial > addition otherwise for the rewiever. > > Therefore, since that script is only about cosmetic in the first place, > let's remove it since it's not worth it. > > Cc: Jani Nikula > Cc: Thierry Reding > Cc: Tomi Valkeinen > Cc: Mark Brown > Signed-off-by: Maxime Ripard Acked-by: Julia Lawall > --- > scripts/coccinelle/api/ptr_ret.cocci | 97 ---------------------------- > 1 file changed, 97 deletions(-) > delete mode 100644 scripts/coccinelle/api/ptr_ret.cocci > > diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci > deleted file mode 100644 > index e76cd5d90a8a..000000000000 > --- a/scripts/coccinelle/api/ptr_ret.cocci > +++ /dev/null > @@ -1,97 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0-only > -/// > -/// Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR > -/// > -// Confidence: High > -// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. > -// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. > -// URL: http://coccinelle.lip6.fr/ > -// Options: --no-includes --include-headers > -// > -// Keywords: ERR_PTR, PTR_ERR, PTR_ERR_OR_ZERO > -// Version min: 2.6.39 > -// > - > -virtual context > -virtual patch > -virtual org > -virtual report > - > -@depends on patch@ > -expression ptr; > -@@ > - > -- if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; > -+ return PTR_ERR_OR_ZERO(ptr); > - > -@depends on patch@ > -expression ptr; > -@@ > - > -- if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; > -+ return PTR_ERR_OR_ZERO(ptr); > - > -@depends on patch@ > -expression ptr; > -@@ > - > -- (IS_ERR(ptr) ? PTR_ERR(ptr) : 0) > -+ PTR_ERR_OR_ZERO(ptr) > - > -@r1 depends on !patch@ > -expression ptr; > -position p1; > -@@ > - > -* if@p1 (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; > - > -@r2 depends on !patch@ > -expression ptr; > -position p2; > -@@ > - > -* if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; > - > -@r3 depends on !patch@ > -expression ptr; > -position p3; > -@@ > - > -* IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0 > - > -@script:python depends on org@ > -p << r1.p1; > -@@ > - > -coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") > - > - > -@script:python depends on org@ > -p << r2.p2; > -@@ > - > -coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") > - > -@script:python depends on org@ > -p << r3.p3; > -@@ > - > -coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") > - > -@script:python depends on report@ > -p << r1.p1; > -@@ > - > -coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") > - > -@script:python depends on report@ > -p << r2.p2; > -@@ > - > -coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") > - > -@script:python depends on report@ > -p << r3.p3; > -@@ > - > -coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used") > -- > 2.24.1 > >