All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] rbd: make the code more readable
@ 2016-10-15  8:26 Xiubo Li
  2016-10-16 16:46 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Xiubo Li @ 2016-10-15  8:26 UTC (permalink / raw)
  To: qemu-block; +Cc: jsnow, qemu-devel, Xiubo Li

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH v2] rbd: make the code more readable
  2016-10-15  8:26 [Qemu-devel] [PATCH v2] rbd: make the code more readable Xiubo Li
@ 2016-10-16 16:46 ` Stefan Hajnoczi
  2016-10-17 16:25 ` [Qemu-devel] " John Snow
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2016-10-16 16:46 UTC (permalink / raw)
  To: Xiubo Li; +Cc: qemu-block, qemu-devel

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

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(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] rbd: make the code more readable
  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 ` John Snow
  2016-10-18 13:53 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
  2016-10-18 19:28 ` Jeff Cody
  3 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2016-10-17 16:25 UTC (permalink / raw)
  To: Xiubo Li, qemu-block; +Cc: qemu-devel



On 10/15/2016 04:26 AM, 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;
>  }
>
>

Reviewed-by: John Snow <jsnow@redhat.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH v2] rbd: make the code more readable
  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 ` Kevin Wolf
  2016-10-18 19:28 ` Jeff Cody
  3 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2016-10-18 13:53 UTC (permalink / raw)
  To: Xiubo Li; +Cc: qemu-block, qemu-devel, jdurgin, jcody

Am 15.10.2016 um 10:26 hat Xiubo Li geschrieben:
> 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.

Copying the official maintainers:

$ scripts/get_maintainer.pl -f block/rbd.c
Josh Durgin <jdurgin@redhat.com> (supporter:RBD)
Jeff Cody <jcody@redhat.com> (supporter:RBD)
...

> 
>  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
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH v2] rbd: make the code more readable
  2016-10-15  8:26 [Qemu-devel] [PATCH v2] rbd: make the code more readable Xiubo Li
                   ` (2 preceding siblings ...)
  2016-10-18 13:53 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
@ 2016-10-18 19:28 ` Jeff Cody
  3 siblings, 0 replies; 5+ messages in thread
From: Jeff Cody @ 2016-10-18 19:28 UTC (permalink / raw)
  To: Xiubo Li; +Cc: qemu-block, qemu-devel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-10-18 19:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.