From: Eduardo Habkost <ehabkost@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: kwolf@redhat.com, qemu-block@nongnu.org,
Markus Armbruster <armbru@redhat.com>,
qemu-devel@nongnu.org, mreitz@redhat.com, borntraeger@de.ibm.com,
cornelia.huck@de.ibm.com
Subject: Re: [Qemu-devel] [PATCH] error: Remove NULL checks on error_propagate() calls
Date: Thu, 9 Jun 2016 17:21:12 -0300 [thread overview]
Message-ID: <20160609202112.GD17952@thinpad.lan.raisama.net> (raw)
In-Reply-To: <5759CD6B.9000407@redhat.com>
On Thu, Jun 09, 2016 at 02:11:23PM -0600, Eric Blake wrote:
> On 06/09/2016 01:50 PM, Eduardo Habkost wrote:
> > On Thu, Jun 09, 2016 at 01:37:23PM -0600, Eric Blake wrote:
> > [...]
> >>
> >> Hmm - it seems like in most of the cases where the ONLY thing done in
> >> the if (local_err) block is to propagate the error, we should instead be
> >> directly assigning to errp instead of wasting a local variable. At this
> >> point, my review is repetitive enough that I'll stop looking, and leave
> >> it up to you and Markus whether to attempt a more ambitious Coccinelle
> >> script.
> >
> > If it happens immediately before the function end or a return
> > statement it should be easy, but it would still require some
> > manual work to remove the unused variable declaration. Probably
> > easier to do that in a follow-up patch.
>
> I think Coccinelle can be used to eliminate unused local variables, but
> don't know the recipe off-hand; maybe a web search will turn up something?
I found something called "when constraints", but the
documentation isn't very clear.
There's an example here:
http://coccinelle.lip6.fr/rules/unused.cocci
>
> >
> > It's harder (impossible?) to make Coccinelle avoid matching if
> > local_err is used somewhere else in the function. But it's
> > probably doable with some manual work, in a follow-up patch.
>
> I don't know - Coccinelle is rather powerful, and there may indeed be a
> way to flag conditions for a variable that is not used anywhere except
> in the lines mentioned in the recipe, vs. a variable that can also be
> used in the ... portion of the recipe.
I found a hackish way to do that. Sending a follow-up patch in 1
minute.
--
Eduardo
next prev parent reply other threads:[~2016-06-09 20:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-09 17:40 [Qemu-devel] [PATCH] error: Remove NULL checks on error_propagate() calls Eduardo Habkost
2016-06-09 19:37 ` Eric Blake
2016-06-09 19:50 ` Eduardo Habkost
2016-06-09 20:11 ` Eric Blake
2016-06-09 20:21 ` Eduardo Habkost [this message]
2016-06-09 20:21 ` [Qemu-devel] [PATCH] error: Avoid redudant error_propagate() usage Eduardo Habkost
2016-06-09 20:47 ` Eduardo Habkost
2016-06-09 20:54 ` Eric Blake
2016-06-09 21:57 ` Eduardo Habkost
2016-06-09 20:57 ` Eric Blake
2016-06-09 21:59 ` Eduardo Habkost
-- strict thread matches above, loose matches on Subject: below --
2018-12-13 17:31 [Qemu-devel] [PATCH] error: Remove NULL checks on error_propagate() calls Markus Armbruster
2018-12-13 21:23 ` Eric Blake
2018-12-14 10:44 ` Philippe Mathieu-Daudé
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=20160609202112.GD17952@thinpad.lan.raisama.net \
--to=ehabkost@redhat.com \
--cc=armbru@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).