From: Julia Lawall <julia.lawall@inria.fr>
To: Denis Efremov <efremov@linux.com>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] Problem with partial patch generation
Date: Mon, 15 Feb 2021 12:47:39 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.22.394.2102151246510.2808@hadrien> (raw)
In-Reply-To: <f3aefcce-4ba1-f49a-c47a-fb6e7a164a19@linux.com>
On Mon, 15 Feb 2021, Denis Efremov wrote:
> Hi,
>
> I wrote a simple rule (swap.cocci):
>
> virtual patch
>
> @depends on patch@
> identifier tmp;
> expression a, b;
> type T;
> @@
>
> (
> - T tmp;
> |
> - T tmp = 0;
> |
> - T *tmp = NULL;
> )
> ... when != tmp
> - tmp = a;
> - a = b;
> - b = tmp;
> + swap(a, b);
> ... when != tmp
>
> I would expect it to remove a local variable only if there is a match
> with swap template.
>
> However, it generates "partial" patch on 5.11 linux code:
> $ spatch --version
> spatch version 1.0.8-00201-g267f9cf8cc82 compiled with OCaml version 4.11.1
> $ spatch -D patch --sp-file swap.cocci mm/filemap.c
> --- mm/filemap.c
> +++ /tmp/cocci-output-445786-88aa66-filemap.c
> @@ -2348,7 +2348,7 @@ static int generic_file_buffered_read_ge
> struct file_ra_state *ra = &filp->f_ra;
> pgoff_t index = iocb->ki_pos >> PAGE_SHIFT;
> pgoff_t last_index = (iocb->ki_pos + iter->count + PAGE_SIZE-1) >> PAGE_SHIFT;
> - int i, j, nr_got, err = 0;
> + int i, nr_got, err = 0;
>
> nr = min_t(unsigned long, last_index - index, nr);
> find_page:
>
> How can I improve the rule?
I don't get a match with the latest version of Coccinelle.
If the latest version of Coccinelle were to become a release, would that
be good enough for you? Or do you need 1.0.8 to work as well?
julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci
next prev parent reply other threads:[~2021-02-15 11:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-15 11:24 [Cocci] Problem with partial patch generation Denis Efremov
2021-02-15 11:45 ` Julia Lawall
2021-02-15 11:47 ` Julia Lawall [this message]
2021-02-15 11:51 ` Denis Efremov
2021-02-15 12:03 ` Julia Lawall
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.2102151246510.2808@hadrien \
--to=julia.lawall@inria.fr \
--cc=cocci@systeme.lip6.fr \
--cc=efremov@linux.com \
/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).