From: Julia Lawall <julia@diku.dk>
To: Joe Perches <joe@perches.com>
Cc: Jay Cliburn <jcliburn@gmail.com>,
Chris Snook <chris.snook@gmail.com>,
atl1-devel@lists.sourceforge.net, Jie Yang <jie.yang@atheros.com>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
arnd@arndb.de
Subject: Re: [PATCH 1/16] drivers/net/atl1c: remove exceptional & on function name
Date: Wed, 18 Nov 2009 22:07:56 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.64.0911182202350.28287@ask.diku.dk> (raw)
In-Reply-To: <1258569615.24178.13.camel@Joe-Laptop.home>
On Wed, 18 Nov 2009, Joe Perches wrote:
> On Wed, 2009-11-18 at 19:20 +0100, Julia Lawall wrote:
> > From: Julia Lawall <julia@diku.dk>
> >
> > In this file, function names are otherwise used as pointers without &.
> >
> > A simplified version of the semantic patch that makes this change is as
> > follows: (http://coccinelle.lip6.fr/)
>
> Hi Julia, thanks for doing this.
>
> Can you please post the complete version of the semantic patch?
There are basically three parts to the following semantic patch. The
first part counts the number of references to functions that do and do not
have & in front of them. For simplicity, a function is considered to be
something that is explicitly defined in the current file. It would be
possible to also consider functions for which there is only a prototype.
The second part, consisting of the python code in the middle considers the
counts and decides which transformation to make, if any. In the end, to
limit the number of files to consider, I just consider files for which
there is only one occurrence of one case and more than 9 occurrences of
the other. The two small python rules after that one throw away all of
the matches of function names that do not correspond to the case that is
desired.
The last few rules do the transformation. Both transformations are put in
one rule, which is safe because all matches for the transformation that is
not wanted have been discarded.
julia
@script:python@
@@
with_and = 0
without_and = 0
@r@
identifier f;
@@
f(...) { ... }
@addr1@
identifier r.f;
position pa;
@@
&f@pa
@script:python@
p << addr1.pa;
@@
with_and = with_and + 1
@r1@
identifier r.f;
position p;
declarer name EXPORT_SYMBOL;
@@
(
EXPORT_SYMBOL(f@p);
|
module_init(f@p);
|
module_exit(f@p);
|
f@p(...)
)
@noaddr1@
identifier r.f;
position pn != r1.p;
@@
(
&f
|
f@pn
)
@script:python@
p << noaddr1.pn;
@@
without_and = without_and + 1
@script:python@
@@
choose_without_and = False
#if (with_and * 25 < without_and):
# choose_without_and = True
if (with_and == 1 and without_and > 9):
choose_without_and = True
choose_with_and = False
#if (without_and * 25 < with_and):
# choose_with_and = True
if (without_and == 1 and with_and > 9):
choose_with_and = True
@script:python@
p << addr1.pa;
f << r.f;
@@
if (choose_with_and or not choose_without_and):
cocci.include_match(False)
@script:python@
p << noaddr1.pn;
f << r.f;
@@
if (choose_without_and or not choose_with_and):
cocci.include_match(False)
@@
identifier f;
position addr1.pa;
position noaddr1.pn;
@@
(
- &f@pa
+ f
|
- f@pn
+ &f
)
next prev parent reply other threads:[~2009-11-18 21:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-18 18:20 Julia Lawall
2009-11-18 18:40 ` Joe Perches
2009-11-18 21:07 ` Julia Lawall [this message]
2009-11-18 18:47 ` David Miller
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=Pine.LNX.4.64.0911182202350.28287@ask.diku.dk \
--to=julia@diku.dk \
--cc=arnd@arndb.de \
--cc=atl1-devel@lists.sourceforge.net \
--cc=chris.snook@gmail.com \
--cc=jcliburn@gmail.com \
--cc=jie.yang@atheros.com \
--cc=joe@perches.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®