From: Denis Efremov <efremov@linux.com>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH] coccinelle: misc: minmax: suppress patch generation for err returns
Date: Tue, 15 Jun 2021 09:13:21 +0300 [thread overview]
Message-ID: <6296d731-60d3-1ceb-226d-ded9d2d5a1f9@linux.com> (raw)
In-Reply-To: <20210428060350.57661-1-efremov@linux.com>
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 <efremov@linux.com>
> ---
> 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)
> ...>
> }
>
prev parent reply other threads:[~2021-06-15 6:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 6:03 [RESEND PATCH] coccinelle: misc: minmax: suppress patch generation for err returns Denis Efremov
2021-06-15 6:13 ` Denis Efremov [this message]
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=6296d731-60d3-1ceb-226d-ded9d2d5a1f9@linux.com \
--to=efremov@linux.com \
--cc=Julia.Lawall@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).