cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: Michal Marek <michal.lkml@markovi.net>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	kernel-janitors@vger.kernel.org,
	Nicolas Palix <nicolas.palix@imag.fr>,
	linux-kernel@vger.kernel.org, Coccinelle <cocci@systeme.lip6.fr>
Subject: Re: [Cocci] [PATCH] Coccinelle: Reduce duplicate code for patch rules of memdup_user.cocci
Date: Sun, 9 Aug 2020 13:25:34 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2008091324530.2450@hadrien> (raw)
In-Reply-To: <b5c83a17-e04f-2d10-9506-12c50b3de9b9@web.de>



On Sun, 9 Aug 2020, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 9 Aug 2020 11:11:20 +0200
>
> Another patch rule was added. A bit of code was copied from a previous
> SmPL rule for this change specification.
>
> * Thus reduce duplicate code by using another SmPL disjunction.

I don't care about this issue.

>
> * Increase the precision a bit for desired source code adjustments.

This gives no information.  If you explain the improvement in an
understandable way, I will consider whether it is useful to take the
patch.

julia

> Fixes: 9c568dbd677bcfc975220d3157c89c48669a23e3 ("coccinelle: api: extend memdup_user rule with vmemdup_user()")
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  scripts/coccinelle/api/memdup_user.cocci | 44 +++++++++---------------
>  1 file changed, 16 insertions(+), 28 deletions(-)
>
> diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci
> index e01e95108405..7cf698b4e925 100644
> --- a/scripts/coccinelle/api/memdup_user.cocci
> +++ b/scripts/coccinelle/api/memdup_user.cocci
> @@ -27,34 +27,22 @@ expression from,to,size;
>  identifier l1,l2;
>  position p : script:python() { relevant(p) };
>  @@
> -
> --  to = \(kmalloc@p\|kzalloc@p\)
> --		(size,\(GFP_KERNEL\|GFP_USER\|
> --		      \(GFP_KERNEL\|GFP_USER\)|__GFP_NOWARN\));
> -+  to = memdup_user(from,size);
> -   if (
> --      to==NULL
> -+      IS_ERR(to)
> -                 || ...) {
> -   <+... when != goto l1;
> --  -ENOMEM
> -+  PTR_ERR(to)
> -   ...+>
> -   }
> --  if (copy_from_user(to, from, size) != 0) {
> --    <+... when != goto l2;
> --    -EFAULT
> --    ...+>
> --  }
> -
> -@depends on patch@
> -expression from,to,size;
> -identifier l1,l2;
> -position p : script:python() { relevant(p) };
> -@@
> -
> --  to = \(kvmalloc@p\|kvzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\));
> -+  to = vmemdup_user(from,size);
> + to =
> +(
> +-     \(kmalloc@p\|kzalloc@p\)
> ++     memdup_user
> +      (
> +-      size, \( \(GFP_KERNEL\|GFP_USER\) \| \(GFP_KERNEL\|GFP_USER\)|__GFP_NOWARN \)
> ++      from, size
> +      )
> +|
> +-     \(kvmalloc@p\|kvzalloc@p\)
> ++     vmemdup_user
> +      (
> +-      size, \(GFP_KERNEL\|GFP_USER\)
> ++      from, size
> +      )
> +);
>     if (
>  -      to==NULL
>  +      IS_ERR(to)
> --
> 2.28.0
>
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

      reply	other threads:[~2020-08-09 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1ae3eefe-fa5a-a497-f00b-5638f4191e90@web.de>
2020-08-09  9:20 ` [Cocci] [PATCH] Coccinelle: Reduce duplicate code for patch rules of memdup_user.cocci Markus Elfring
2020-08-09 11:25   ` Julia Lawall [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=alpine.DEB.2.22.394.2008091324530.2450@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=Gilles.Muller@lip6.fr \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@systeme.lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --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;
as well as URLs for NNTP newsgroup(s).