From: Julia Lawall <julia.lawall@lip6.fr>
To: Johan Hovold <johan@kernel.org>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>,
Michal Marek <mmarek@suse.com>,
Gilles Muller <Gilles.Muller@lip6.fr>,
Nicolas Palix <nicolas.palix@imag.fr>,
linux-kernel@vger.kernel.org, cocci@systeme.lip6.fr
Subject: Re: [PATCH] coccinelle: misc: remove "complex return code" warnings
Date: Sat, 3 Oct 2015 18:25:39 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.10.1510031825170.2586@hadrien> (raw)
In-Reply-To: <1443652647-23097-1-git-send-email-johan@kernel.org>
Should have acked this message...
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
On Wed, 30 Sep 2015, Johan Hovold wrote:
> This effectively reverts 932058a5d5f9 ("coccinelle: misc: semantic patch
> to delete overly complex return code processing").
>
> There can be both symmetry and readability reasons for not wanting to do
> the final function call as part of the return statement and to maintain
> a clear separation of success and error paths.
>
> Since this is in no way mandated by the coding standard, let's just
> remove this semantic patch to avoid having "clean up" patches being
> posted over and over in response to these Coccinelle warnings.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> scripts/coccinelle/misc/simple_return.cocci | 180 ----------------------------
> 1 file changed, 180 deletions(-)
> delete mode 100644 scripts/coccinelle/misc/simple_return.cocci
>
> diff --git a/scripts/coccinelle/misc/simple_return.cocci b/scripts/coccinelle/misc/simple_return.cocci
> deleted file mode 100644
> index e8b6313b116f..000000000000
> --- a/scripts/coccinelle/misc/simple_return.cocci
> +++ /dev/null
> @@ -1,180 +0,0 @@
> -/// Simplify a trivial if-return sequence. Possibly combine with a
> -/// preceding function call.
> -///
> -// Confidence: High
> -// Copyright: (C) 2014 Julia Lawall, INRIA/LIP6. GPLv2.
> -// Copyright: (C) 2014 Gilles Muller, INRIA/LiP6. GPLv2.
> -// URL: http://coccinelle.lip6.fr/
> -// Comments:
> -// Options: --no-includes --include-headers
> -
> -virtual patch
> -virtual context
> -virtual org
> -virtual report
> -
> -@r depends on patch@
> -local idexpression e;
> -identifier i,f,fn;
> -@@
> -
> -fn(...) { <...
> -- e@i =
> -+ return
> - f(...);
> --if (i != 0) return i;
> --return 0;
> -...> }
> -
> -@depends on patch@
> -identifier r.i;
> -type t;
> -@@
> -
> --t i;
> - ... when != i
> -
> -@depends on patch@
> -expression e;
> -@@
> -
> --if (e != 0)
> - return e;
> --return 0;
> -
> -// -----------------------------------------------------------------------
> -
> -@s1 depends on context || org || report@
> -local idexpression e;
> -identifier i,f,fn;
> -position p,p1,p2;
> -@@
> -
> -fn(...) { <...
> -* e@i@p = f(...);
> - if (\(i@p1 != 0\|i@p2 < 0\))
> - return i;
> - return 0;
> -...> }
> -
> -@s2 depends on context || org || report forall@
> -identifier s1.i;
> -type t;
> -position q,s1.p;
> -expression e,f;
> -@@
> -
> -* t i@q;
> - ... when != i
> - e@p = f(...);
> -
> -@s3 depends on context || org || report@
> -expression e;
> -position p1!=s1.p1;
> -position p2!=s1.p2;
> -@@
> -
> -*if (\(e@p1 != 0\|e@p2 < 0\))
> - return e;
> - return 0;
> -
> -// -----------------------------------------------------------------------
> -
> -@script:python depends on org@
> -p << s1.p;
> -p1 << s1.p1;
> -q << s2.q;
> -@@
> -
> -cocci.print_main("decl",q)
> -cocci.print_secs("use",p)
> -cocci.include_match(False)
> -
> -@script:python depends on org@
> -p << s1.p;
> -p2 << s1.p2;
> -q << s2.q;
> -@@
> -
> -cocci.print_main("decl",q)
> -cocci.print_secs("use with questionable test",p)
> -cocci.include_match(False)
> -
> -@script:python depends on org@
> -p << s1.p;
> -p1 << s1.p1;
> -@@
> -
> -cocci.print_main("use",p)
> -
> -@script:python depends on org@
> -p << s1.p;
> -p2 << s1.p2;
> -@@
> -
> -cocci.print_main("use with questionable test",p)
> -
> -@script:python depends on org@
> -p << s3.p1;
> -@@
> -
> -cocci.print_main("test",p)
> -
> -@script:python depends on org@
> -p << s3.p2;
> -@@
> -
> -cocci.print_main("questionable test",p)
> -
> -// -----------------------------------------------------------------------
> -
> -@script:python depends on report@
> -p << s1.p;
> -p1 << s1.p1;
> -q << s2.q;
> -@@
> -
> -msg = "WARNING: end returns can be simpified and declaration on line %s can be dropped" % (q[0].line)
> -coccilib.report.print_report(p[0],msg)
> -cocci.include_match(False)
> -
> -@script:python depends on report@
> -p << s1.p;
> -p1 << s1.p1;
> -q << s2.q
> -;
> -@@
> -
> -msg = "WARNING: end returns may be simpified if negative or 0 value and declaration on line %s can be dropped" % (q[0].line)
> -coccilib.report.print_report(p[0],msg)
> -cocci.include_match(False)
> -
> -@script:python depends on report@
> -p << s1.p;
> -p1 << s1.p1;
> -@@
> -
> -msg = "WARNING: end returns can be simpified"
> -coccilib.report.print_report(p[0],msg)
> -
> -@script:python depends on report@
> -p << s1.p;
> -p2 << s1.p2;
> -@@
> -
> -msg = "WARNING: end returns can be simpified if negative or 0 value"
> -coccilib.report.print_report(p[0],msg)
> -
> -@script:python depends on report@
> -p << s3.p1;
> -@@
> -
> -msg = "WARNING: end returns can be simpified"
> -coccilib.report.print_report(p[0],msg)
> -
> -@script:python depends on report@
> -p << s3.p2;
> -@@
> -
> -msg = "WARNING: end returns can be simpified if tested value is negative or 0"
> -coccilib.report.print_report(p[0],msg)
> --
> 2.4.9
>
>
next prev parent reply other threads:[~2015-10-03 16:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-30 22:37 Johan Hovold
2015-10-01 5:20 ` Julia Lawall
2015-10-01 17:47 ` Johan Hovold
2015-10-02 21:33 ` Julia Lawall
2015-10-04 10:50 ` Johan Hovold
2015-10-03 16:24 ` Julia Lawall
2015-10-04 10:52 ` Johan Hovold
2015-10-03 16:25 ` Julia Lawall [this message]
2015-10-28 9:54 ` Johan Hovold
2015-10-28 10:04 ` Michal Marek
2015-10-28 10:09 ` Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.10.1510031825170.2586@hadrien \
--to=julia.lawall@lip6.fr \
--cc=Gilles.Muller@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.com \
--cc=nicolas.palix@imag.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®