qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: Xiubo Li <lixiubo@cmss.chinamobile.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v2] rbd: make the code more readable
Date: Tue, 18 Oct 2016 15:28:32 -0400	[thread overview]
Message-ID: <20161018192832.GA14251@localhost.localdomain> (raw)
In-Reply-To: <1476519973-6436-1-git-send-email-lixiubo@cmss.chinamobile.com>

On Sat, Oct 15, 2016 at 04:26:13PM +0800, Xiubo Li wrote:
> Make it a bit clearer and more readable.
> 
> Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
> CC: John Snow <jsnow@redhat.com>
> ---
> 
> V2:
> - Advice from John Snow. Thanks.
> 
> 
>  block/rbd.c | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index 0a5840d..d0d4b39 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -366,45 +366,44 @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
>          rados_conf_read_file(cluster, NULL);
>      } else if (conf[0] != '\0' &&
>                 qemu_rbd_set_conf(cluster, conf, true, &local_err) < 0) {
> -        rados_shutdown(cluster);
>          error_propagate(errp, local_err);
> -        return -EIO;
> +        ret = -EIO;
> +        goto shutdown;
>      }
>  
>      if (conf[0] != '\0' &&
>          qemu_rbd_set_conf(cluster, conf, false, &local_err) < 0) {
> -        rados_shutdown(cluster);
>          error_propagate(errp, local_err);
> -        return -EIO;
> +        ret = -EIO;
> +        goto shutdown;
>      }
>  
>      if (qemu_rbd_set_auth(cluster, secretid, errp) < 0) {
> -        rados_shutdown(cluster);
> -        return -EIO;
> +        ret = -EIO;
> +        goto shutdown;
>      }
>  
>      ret = rados_connect(cluster);
>      if (ret < 0) {
>          error_setg_errno(errp, -ret, "error connecting");
> -        rados_shutdown(cluster);
> -        return ret;
> +        goto shutdown;
>      }
>  
>      ret = rados_ioctx_create(cluster, pool, &io_ctx);
>      if (ret < 0) {
>          error_setg_errno(errp, -ret, "error opening pool %s", pool);
> -        rados_shutdown(cluster);
> -        return ret;
> +        goto shutdown;
>      }
>  
>      ret = rbd_create(io_ctx, name, bytes, &obj_order);
> -    rados_ioctx_destroy(io_ctx);
> -    rados_shutdown(cluster);
>      if (ret < 0) {
>          error_setg_errno(errp, -ret, "error rbd create");
> -        return ret;
>      }
>  
> +    rados_ioctx_destroy(io_ctx);
> +
> +shutdown:
> +    rados_shutdown(cluster);
>      return ret;
>  }
>  
> -- 
> 1.8.3.1
> 
> 
> 
> 

Thanks,

Applied to my block branch:

git://github.com/codyprime/qemu-kvm-jtc.git block

-Jeff

      parent reply	other threads:[~2016-10-18 19:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-15  8:26 [Qemu-devel] [PATCH v2] rbd: make the code more readable Xiubo Li
2016-10-16 16:46 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-10-17 16:25 ` [Qemu-devel] " John Snow
2016-10-18 13:53 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2016-10-18 19:28 ` Jeff Cody [this message]

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=20161018192832.GA14251@localhost.localdomain \
    --to=jcody@redhat.com \
    --cc=lixiubo@cmss.chinamobile.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).