qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	Michael Tokarev <mjt@tls.msk.ru>,
	qemu-devel <qemu-devel@nongnu.org>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] block: Remove unused assignment (fixes warning from clang)
Date: Mon, 30 Sep 2013 09:57:03 +0200	[thread overview]
Message-ID: <20130930075703.GA2507@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <52488A4E.5010902@weilnetz.de>

Am 29.09.2013 um 22:15 hat Stefan Weil geschrieben:
> Am 29.09.2013 21:44, schrieb Michael Tokarev:
> > 28.09.2013 13:55, Stefan Weil wrote:
> [...]
> >> diff --git a/blockdev.c b/blockdev.c
> >> index 8aa66a9..8c83f6f 100644
> >> --- a/blockdev.c
> >> +++ b/blockdev.c
> >> @@ -1926,7 +1926,6 @@ void qmp_drive_mirror(const char *device, const
> >> char *target,
> >>       } else {
> >>           switch (mode) {
> >>           case NEW_IMAGE_MODE_EXISTING:
> >> -            ret = 0;
> >>               break;
> >
> > While this one is obviously unused assignment,
> > there's on more usage of `ret' variable in this
> > function, -- it is to store the return value
> > from bdrv_open():
> >
> >     ret = bdrv_open(target_bs, target, NULL, flags |
> > BDRV_O_NO_BACKING, drv,
> >                     &local_err);
> >     if (ret < 0) {...
> >
> > What's the rule about converting that into if() ?
> >
> > Thanks,
> >
> > /mjt
> 
> Is there a rule for cases like that? This pattern is very common in QEMU
> code
> (several occurrences in blockdev.c). Should we eliminate the 'ret' variable?
> I don't think it's worth the effort.

And actually I think removing it would make the code worse (less
readable).

Kevin

  reply	other threads:[~2013-09-30  7:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-28  9:55 [Qemu-devel] [PATCH] block: Remove unused assignment (fixes warning from clang) Stefan Weil
2013-09-29 19:44 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-09-29 20:15   ` Stefan Weil
2013-09-30  7:57     ` Kevin Wolf [this message]
2013-09-30  9:16     ` Stefan Hajnoczi

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=20130930075703.GA2507@dhcp-200-207.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=sw@weilnetz.de \
    /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).