From: Greg Dietsche <gregory.dietsche@cuw.edu>
To: Julia Lawall <julia@diku.dk>
Cc: Gilles.Muller@lip6.fr, npalix.work@gmail.com, cocci@diku.dk,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] coccinelle: if (ret) return ret; return ret; semantic patch
Date: Mon, 13 Jun 2011 15:55:15 -0500 [thread overview]
Message-ID: <4DF67933.9080707@cuw.edu> (raw)
In-Reply-To: <Pine.LNX.4.64.1106132033460.24125@ask.diku.dk>
On 06/13/2011 01:38 PM, Julia Lawall wrote:
> How about:
>
> @@
> identifier f;
> expression ret;
> identifier x;
> @@
>
> (
> - if (likely(x)) return ret;
> |
> - if (\(IS_ERR\|IS_ZERO\|is_ordinal_table\)(x)) return ret;
> |
> if (<+...f(...)...+>) return ret;
> |
> - if (...) return ret;
> )
> return ret;
>
>
just curious... i see you usually just write "return ret;" here when
posting. I've assumed that's because it will 1) work and 2) is close enough.
You'll notice I've been doing:
-return ret;
+return ret;
because it seems to help coccinelle realize that it can get rid of extra
line feeds - does this make sense - or should i just be doing a "return
ret"?
> I have put the likely case separate from the other function calls to
> benefit from the isomorphism. I have restricted the argument to these
> functions to be an identifier so that it won't have any side effects. It
> doesn't have to be the same as ret though. The third line keeps all other
> ifs that contain function calls. The fourth line gets rid of everything
> else.
>
> You could see if this finds all of the cases of your proposed rule and if
> it at least doesn't find anything else that you don't want it to find.
>
>
I'll try it out this afternoon/evening hopefully.
> julia
>
>
There are two other issues with the patch that I've noticed. I'll be
teaching myself more on coccinelle to figure these out. Unless someone
else wants to jump in :) So far I've read or skimmed a number of paper's
that have been written on Coccinelle... I find it all very interesting :)
1) sometimes you see this type of code - which i've chosen to ignore for
now:
if ((ret=XXXXX) < 0)
return ret;
return ret;
which could just be simplified to:
return XXXXX;
for an example see the function load_firmware in
sound/pci/echoaudio/echoaudio_dsp.c
2) after the semantic patch has removed an "if (...)return ret;" Quite
often, but not always, we end up with this:
ret=...;
return ret;
which of course could just become
return ...;
So as you can see the problems are quite similar, but a little different.
Greg
next prev parent reply other threads:[~2011-06-13 20:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 0:26 [PATCH] coccinelle: if(ret)return ret; return ret; semantic patch Greg Dietsche
2011-06-06 4:55 ` Julia Lawall
2011-06-07 15:47 ` Greg Dietsche
2011-06-07 16:56 ` Julia Lawall
2011-06-07 21:54 ` Nicolas Palix
2011-06-07 22:59 ` Greg Dietsche
2011-06-08 7:11 ` Nicolas Palix
2011-06-08 7:24 ` Julia Lawall
2011-06-11 15:37 ` Greg Dietsche
2011-06-11 15:43 ` Julia Lawall
2011-06-06 4:56 ` Julia Lawall
2011-06-13 18:23 ` [PATCH v2] coccinelle: if (ret) return " Greg Dietsche
2011-06-13 18:36 ` Joe Perches
2011-06-13 18:38 ` Julia Lawall
2011-06-13 20:55 ` Greg Dietsche [this message]
2011-06-14 5:50 ` Julia Lawall
2011-06-14 21:24 ` Greg Dietsche
2011-06-15 1:15 ` Greg Dietsche
2011-06-15 5:58 ` Julia Lawall
2011-06-15 15:33 ` [Cocci] " Greg Dietsche
2011-06-15 15:34 ` Julia Lawall
2011-06-15 15:35 ` Julia Lawall
2011-06-15 16:05 ` Greg Dietsche
2011-06-15 1:29 ` [PATCH v3] " Greg Dietsche
2011-06-15 5:50 ` Julia Lawall
2011-06-15 15:50 ` [PATCH v4] " Greg Dietsche
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=4DF67933.9080707@cuw.edu \
--to=gregory.dietsche@cuw.edu \
--cc=Gilles.Muller@lip6.fr \
--cc=cocci@diku.dk \
--cc=julia@diku.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=npalix.work@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.