cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Ira Weiny <ira.weiny@intel.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: cocci@systeme.lip6.fr
Subject: Re: [Cocci] Automating a kmap/mem*/kunmap transformation
Date: Mon, 30 Nov 2020 14:48:04 -0800	[thread overview]
Message-ID: <20201130224803.GA1447340@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <13b5bbf1-4dda-9dc2-46cd-a98e71537769@web.de>

On Sun, Nov 29, 2020 at 11:17:14AM +0100, Markus Elfring wrote:
> > 1) How do I get matches to iterate?
> 
> How do you think about possibilities for “iteration”?
> 
> 
> >	1a) What is the difference between '<+... ...+>' and '<... ...>'?
> 
> I suggest to take another look at the section “Dot variants” in the available
> software documentation.
> https://coccinelle.gitlabpages.inria.fr/website/docs/main_grammar004.html#sec7
> 
> Would you like to distinguish if you are looking for source code parts
> which can be optional?

Yes, not every file will have the pattern I'm looking for and as I explained in
my other thread the second instance of that pattern was not being matched and I
could not understand why.  In that case either '+' or no '+' should (and as I
know now does) work.  But I thought there was some secret to them I was
missing...  Sorry...

> 
> 
> > 2) Why can't I get the type declaration (type VP;) matched correctly.  It works
> >    some times but not always.  It also matches a lot of random declarations?
> 
> I imagine that it will help to point a few source code places out
> where you find the shown transformation approach improvable.
> 
> 
> > 2a) and for some reason in the more advanced script[3] it completely breaks.
> 
> How does such an undesirable failure look like?
> 
> I wonder a bit more about the detail why you would like to enclose
> the SmPL code by the construct “<... … ...>” here.

Because of the second instance of my pattern not matching I thought I needed to
specify that the pattern could appear 0 or more times.  But I now realize that
the pattern specification was wrong.

> I find that the change specification “-VP ptr;” would mean then that
> all variable declarations should be deleted for selected source files.


> 
> 
> Would you become interested in any more code alternatives for scripts
> in the semantic patch language?
> 
> Examples:
> A)
> (
> -ptr = kmap(page);
> |
> -ptr = kmap_atomic(page);
> )
> 
> 
> This SmPL disjunction for a deletion approach can be transformed
> like the following.
> 
> -ptr = \( kmap \| kmap_atomic \) (page);

Thanks yes that helps.

> 
> 
> B)
> (
> -memset(...);
> +memIra();
> |
> -memcpy(...);
> +memIra();
> )
> 
> 
> This SmPL disjunction for a replacement approach can eventually be transformed
> like the following.
> 
> -\( memset \| memcpy \) (...)
> +memIra()
>  ;

This makes sense but it is not my final goal and the final goal requires more
manipulation of the parameters to memset/memcpy.

But I am curious to learn more so I'll keep these alternatives in mind.

Thanks!
Ira

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

      parent reply	other threads:[~2020-11-30 22:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-28  5:41 [Cocci] Itterating matches Ira Weiny
2020-11-28  7:55 ` Julia Lawall
2020-11-30 19:19   ` Ira Weiny
2020-11-30 19:59     ` Julia Lawall
2020-11-30 21:06       ` Ira Weiny
2020-12-01 10:06         ` Julia Lawall
     [not found] ` <13b5bbf1-4dda-9dc2-46cd-a98e71537769@web.de>
2020-11-30 22:48   ` Ira Weiny [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=20201130224803.GA1447340@iweiny-DESK2.sc.intel.com \
    --to=ira.weiny@intel.com \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@systeme.lip6.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).