[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/13] block/gluster: auto-ify URI parsing variables
From: |
Marc-André Lureau |
Subject: |
[PATCH 07/13] block/gluster: auto-ify URI parsing variables |
Date: |
Thu, 9 Jul 2020 23:42:28 +0400 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
block/gluster.c | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/block/gluster.c b/block/gluster.c
index 31233cac696..c06eca1c12f 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -349,10 +349,10 @@ static int qemu_gluster_parse_uri(BlockdevOptionsGluster
*gconf,
const char *filename)
{
SocketAddress *gsconf;
- URI *uri;
- QueryParams *qp = NULL;
+ g_autoptr(URI) uri = NULL;
+ g_autoptr(QueryParams) qp = NULL;
bool is_unix = false;
- int ret = 0;
+ int ret;
uri = uri_parse(filename);
if (!uri) {
@@ -374,29 +374,25 @@ static int qemu_gluster_parse_uri(BlockdevOptionsGluster
*gconf,
gsconf->type = SOCKET_ADDRESS_TYPE_INET;
warn_report("rdma feature is not supported, falling back to tcp");
} else {
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
ret = parse_volume_options(gconf, uri->path);
if (ret < 0) {
- goto out;
+ return ret;
}
qp = query_params_parse(uri->query);
if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) {
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
if (is_unix) {
if (uri->server || uri->port) {
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
if (strcmp(qp->p[0].name, "socket")) {
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
gsconf->u.q_unix.path = g_strdup(qp->p[0].value);
} else {
@@ -408,12 +404,7 @@ static int qemu_gluster_parse_uri(BlockdevOptionsGluster
*gconf,
}
}
-out:
- if (qp) {
- query_params_free(qp);
- }
- uri_free(uri);
- return ret;
+ return 0;
}
static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
--
2.27.0.221.ga08a83db2b
- [PATCH 00/13] RFC: use upcoming GUri for URI handling, Marc-André Lureau, 2020/07/09
- [PATCH 01/13] uri: add g_auto macros for URI & QueryParams, Marc-André Lureau, 2020/07/09
- [PATCH 02/13] block/nbd: auto-ify URI parsing variables, Marc-André Lureau, 2020/07/09
- [PATCH 03/13] block/vxhs: auto-ify URI parsing variables, Marc-André Lureau, 2020/07/09
- [PATCH 04/13] block/sheepdog: auto-ify URI parsing variables, Marc-André Lureau, 2020/07/09
- [PATCH 05/13] block/ssh: auto-ify URI parsing variables, Marc-André Lureau, 2020/07/09
- [PATCH 06/13] block/nfs: auto-ify URI parsing variables, Marc-André Lureau, 2020/07/09
- [PATCH 07/13] block/gluster: auto-ify URI parsing variables,
Marc-André Lureau <=
- [PATCH 08/13] build-sys: add HAVE_GLIB_GURI, Marc-André Lureau, 2020/07/09
- [PATCH 09/13] nbd: add GUri-based URI parsing version, Marc-André Lureau, 2020/07/09
- [PATCH 10/13] sheepdog: add GUri-based URI parsing, Marc-André Lureau, 2020/07/09
- [PATCH 11/13] nfs: add GUri-based URI parsing, Marc-André Lureau, 2020/07/09
- [PATCH 12/13] gluster: add GUri-based URI parsing, Marc-André Lureau, 2020/07/09
- [PATCH 13/13] ssh: add GUri-based URI parsing, Marc-André Lureau, 2020/07/09