[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6296d731-60d3-1ceb-226d-ded9d2d5a1f9@linux.com>
Date: Tue, 15 Jun 2021 09:13:21 +0300
From: Denis Efremov <efremov@...ux.com>
To: Julia Lawall <Julia.Lawall@...6.fr>
Cc: cocci@...teme.lip6.fr, linux-kernel@...r.kernel.org
Subject: Re: [RESEND PATCH] coccinelle: misc: minmax: suppress patch
generation for err returns
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@...ux.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.
> +@...code 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)
> ...>
> }
>
Powered by blists - more mailing lists