cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: joel@joelfernandes.org (Joel Fernandes)
To: cocci@systeme.lip6.fr
Subject: [Cocci] Searching for parameter usages of pte_alloc()
Date: Thu, 11 Oct 2018 09:49:34 -0700	[thread overview]
Message-ID: <20181011164934.GA213196@joelaf.mtv.corp.google.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1810111833410.3392@hadrien>

On Thu, Oct 11, 2018 at 06:40:22PM +0200, Julia Lawall wrote:
> > Sure, so if I have code like this:
> > #define pte_alloc_one(mm, vmaddr) ((pte_t *) page_table_alloc(mm))
> >
> > I want to have a rule that does:
> > - #define pte_alloc_one(mm, vmaddr) ((pte_t *) page_table_alloc(mm))
> > + #define pte_alloc_one(mm) ((pte_t *) page_table_alloc(mm))
> >
> > So far everything I tried only works for functions so I was wondering how one
> > do this with macros.
> 
> Maybe
> 
> @r@
> position p;
> identifier i,a,b;
> @@
> 
> #define i(a,b)@p <+...b...+>
> 
> @@
> position p != r.p;
> identifier i,a,b;
> expresssion e;
> @@
> 
> - #define i(a,b)@p e
> + #define i(a) e
> 
> The rule r finds #defines that refer to the second argument, and records
> their position in p, while the second rule finds all other #defines with
> two arguments.

Thanks a lot, I will try these.

> Of course, you would want to use a regular expression for the macro name,
> or do something to avoid changing all two argument macros.
> 
> Macros are often defined in header files, so you may want to use the
> command line options --no-includes --include-headers.  --no-includes means
> ignore header files when they are included into .c files and
> --include-headers means treat both .c an .h files.  Otherwise, you only get
> .c files.

 I am using --include-headers. I didn't get the --no-includes use with
 --include-headers though.

What happens if I don't pass --no-includes?  Do the header files included
from C files also get matched then? Then in that case I shouldn't need to
pass anything (neither --include-headers nor --no-includes) and all included
headers from C files should also be matched/parsed/patched - since every
header should atleast be included *somewhere* otherwise its existinence is
pointless. Could you help me understand this better? Thanks a lot!

 - Joel

  reply	other threads:[~2018-10-11 16:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10 19:38 [Cocci] First coccinelle script, need some help Joel Fernandes
2018-10-10 20:23 ` Julia Lawall
2018-10-10 20:45   ` Joel Fernandes
2018-10-10 20:51     ` Julia Lawall
2018-10-10 21:11       ` Joel Fernandes
2018-10-10 21:12         ` Julia Lawall
     [not found]         ` <93da55ff-c807-6587-7ef3-3d2af820117d@users.sourceforge.net>
2018-10-11 15:43           ` [Cocci] Searching for parameter usages of pte_alloc() Joel Fernandes
2018-10-11 15:51             ` Julia Lawall
2018-10-11 16:28               ` Joel Fernandes
2018-10-11 16:40                 ` Julia Lawall
2018-10-11 16:49                   ` Joel Fernandes [this message]
2018-10-11 16:57                     ` Julia Lawall
2018-10-11 17:06                       ` Joel Fernandes
2018-10-11 18:06                   ` Joel Fernandes
2018-10-11 18:07                   ` Joel Fernandes
     [not found]             ` <cd2eb29e-775f-9c48-b839-b2ebdc3e3c56@users.sourceforge.net>
2018-10-11 23:54               ` Joel Fernandes

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=20181011164934.GA213196@joelaf.mtv.corp.google.com \
    --to=joel@joelfernandes.org \
    --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).