All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Reda Sallahi <fullmanet@gmail.com>,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu-img: don't shadow opts variable in img_dd()
Date: Wed, 21 Jun 2017 09:24:34 +0100	[thread overview]
Message-ID: <20170621082434.GA16183@stefanha-x1.localdomain> (raw)
In-Reply-To: <117743be-2351-7fe0-c777-c630bb850447@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]

On Mon, Jun 19, 2017 at 05:18:18PM +0200, Max Reitz wrote:
> On 2017-06-19 17:00, Stefan Hajnoczi wrote:
> > It's confusing when two different variables have the same name in one
> > function.
> > 
> > Cc: Reda Sallahi <fullmanet@gmail.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >  qemu-img.c | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> > 
> > diff --git a/qemu-img.c b/qemu-img.c
> > index 0ad698d..c285c2f 100644
> > --- a/qemu-img.c
> > +++ b/qemu-img.c
> > @@ -4249,15 +4249,12 @@ static int img_dd(int argc, char **argv)
> >          case 'U':
> >              force_share = true;
> >              break;
> > -        case OPTION_OBJECT: {
> > -            QemuOpts *opts;
> > -            opts = qemu_opts_parse_noisily(&qemu_object_opts,
> > -                                           optarg, true);
> > -            if (!opts) {
> > +        case OPTION_OBJECT:
> > +            if (!qemu_opts_parse_noisily(&qemu_object_opts, optarg, true)) {
> >                  ret = -1;
> >                  goto out;
> >              }
> > -        }   break;
> > +            break;
> >          case OPTION_IMAGE_OPTS:
> >              image_opts = true;
> >              break;
> 
> Hm, I basically reverted such a style in commit
> 3258b91141090b05edcaab8f1d1dd355ca91b49a. I find it confusing to use the
> same variable for two different things.

I don't follow how the commit you posted is related to this patch.  Did
you read the patch too quickly and think it uses the outer opts
variable?

This patch doesn't use a variable at all - there is no need for one.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2017-06-21  8:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19 15:00 [Qemu-devel] [PATCH] qemu-img: don't shadow opts variable in img_dd() Stefan Hajnoczi
2017-06-19 15:18 ` Max Reitz
2017-06-21  8:24   ` Stefan Hajnoczi [this message]
2017-06-21 11:30     ` Max Reitz
2017-06-20  0:56 ` no-reply
2017-06-21  8:25   ` 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=20170621082434.GA16183@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=fullmanet@gmail.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 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.