From: Fabio Aiuto <fabioaiuto83@gmail.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: gregkh@linuxfoundation.org, joe@perches.com,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: cocci script hints request
Date: Tue, 13 Apr 2021 12:07:26 +0200 [thread overview]
Message-ID: <20210413100725.GC5477@agape.jhs> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2104131154100.2872@hadrien>
On Tue, Apr 13, 2021 at 11:56:20AM +0200, Julia Lawall wrote:
>
>
> On Tue, 13 Apr 2021, Fabio Aiuto wrote:
>
> > Hi,
> >
> > I would like to improve the following coccinelle script:
> >
> > @@
> > expression a, fmt;
> > expression list var_args;
> > @@
> >
> > - DBG_871X_LEVEL(a, fmt, var_args);
> > + printk(fmt, var_args);
> >
> > I would replace the DBG_871X_LEVEL macro with printk, but
> > I can't find a way to add KERN_* constant prefix to the fmt
> > argument in the + code line. If i try this
> >
> > @@
> > expression a, fmt;
> > expression list var_args;
> > @@
> >
> > - DBG_871X_LEVEL(a, fmt, var_args);
> > + printk(KERN_DEBUG fmt, var_args);
> >
> > plus: parse error:
> > File "../test.cocci", line 94, column 20, charpos = 1171
> > around = 'fmt',
> > whole content = + printk(KERN_DEBUG fmt, var_args);
> >
> > how could I do this?
>
> Although I certainly agree with Greg, I'll answer the question from a
> technical point of view.
>
> I'm not sure that that kind of compound string is supported for a
> metavariable. It is possible to get around this problem using a python
> script. If you ever need to do this for a better reason, you can take a
> look at demos/pythontococci.cocci in the Coccinelle source code
> distribution.
>
> julia
thank you, this helps a lot!
fabio
prev parent reply other threads:[~2021-04-13 10:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-13 9:04 cocci script hints request Fabio Aiuto
2021-04-13 9:11 ` Greg KH
2021-04-13 9:24 ` Fabio Aiuto
2021-04-13 9:42 ` Greg KH
2021-04-13 9:56 ` Julia Lawall
2021-04-13 10:07 ` Fabio Aiuto [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=20210413100725.GC5477@agape.jhs \
--to=fabioaiuto83@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=julia.lawall@inria.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/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