qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	integration@gluster.org, sheepdog@lists.wpkg.org,
	qemu-block@nongnu.org, Peter Lieven <pl@kamp.de>,
	qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
	Liu Yuan <namei.unix@gmail.com>
Subject: Re: [PATCH 05/13] block/ssh: auto-ify URI parsing variables
Date: Thu, 23 Jul 2020 13:30:04 +0100	[thread overview]
Message-ID: <20200723123004.GO3888@redhat.com> (raw)
In-Reply-To: <20200709194234.2117650-6-marcandre.lureau@redhat.com>

On Thu, Jul 09, 2020 at 11:42:26PM +0400, Marc-André Lureau wrote:
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  block/ssh.c | 23 +++++++----------------
>  1 file changed, 7 insertions(+), 16 deletions(-)
> 
> diff --git a/block/ssh.c b/block/ssh.c
> index 098dbe03c15..c8f6ad79e3c 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -180,9 +180,9 @@ static void sftp_error_trace(BDRVSSHState *s, const char *op)
>  
>  static int parse_uri(const char *filename, QDict *options, Error **errp)
>  {
> -    URI *uri = NULL;
> -    QueryParams *qp;
> -    char *port_str;
> +    g_autoptr(URI) uri = NULL;
> +    g_autoptr(QueryParams) qp = NULL;
> +    g_autofree char *port_str = NULL;
>      int i;
>  
>      uri = uri_parse(filename);
> @@ -192,23 +192,23 @@ static int parse_uri(const char *filename, QDict *options, Error **errp)
>  
>      if (g_strcmp0(uri->scheme, "ssh") != 0) {
>          error_setg(errp, "URI scheme must be 'ssh'");
> -        goto err;
> +        return -EINVAL;
>      }
>  
>      if (!uri->server || strcmp(uri->server, "") == 0) {
>          error_setg(errp, "missing hostname in URI");
> -        goto err;
> +        return -EINVAL;
>      }
>  
>      if (!uri->path || strcmp(uri->path, "") == 0) {
>          error_setg(errp, "missing remote path in URI");
> -        goto err;
> +        return -EINVAL;
>      }
>  
>      qp = query_params_parse(uri->query);
>      if (!qp) {
>          error_setg(errp, "could not parse query parameters");
> -        goto err;
> +        return -EINVAL;
>      }
>  
>      if(uri->user && strcmp(uri->user, "") != 0) {
> @@ -219,7 +219,6 @@ static int parse_uri(const char *filename, QDict *options, Error **errp)
>  
>      port_str = g_strdup_printf("%d", uri->port ?: 22);
>      qdict_put_str(options, "server.port", port_str);
> -    g_free(port_str);
>  
>      qdict_put_str(options, "path", uri->path);
>  
> @@ -232,15 +231,7 @@ static int parse_uri(const char *filename, QDict *options, Error **errp)
>          }
>      }
>  
> -    query_params_free(qp);
> -    uri_free(uri);
>      return 0;
> -
> - err:
> -    if (uri) {
> -      uri_free(uri);
> -    }
> -    return -EINVAL;
>  }
>  

I had to look up the definition of g_autoptr, and it seems fine
since there's a corresponding URI macro added in the first commit.

ACK

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org



  reply	other threads:[~2020-07-23 12:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09 19:42 [PATCH 00/13] RFC: use upcoming GUri for URI handling Marc-André Lureau
2020-07-09 19:42 ` [PATCH 01/13] uri: add g_auto macros for URI & QueryParams Marc-André Lureau
2020-07-09 19:42 ` [PATCH 02/13] block/nbd: auto-ify URI parsing variables Marc-André Lureau
2020-07-09 19:42 ` [PATCH 03/13] block/vxhs: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 04/13] block/sheepdog: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 05/13] block/ssh: " Marc-André Lureau
2020-07-23 12:30   ` Richard W.M. Jones [this message]
2020-07-09 19:42 ` [PATCH 06/13] block/nfs: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 07/13] block/gluster: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 08/13] build-sys: add HAVE_GLIB_GURI Marc-André Lureau
2020-07-09 19:42 ` [PATCH 09/13] nbd: add GUri-based URI parsing version Marc-André Lureau
2020-07-10  8:31   ` Daniel P. Berrangé
2020-07-09 19:42 ` [PATCH 10/13] sheepdog: add GUri-based URI parsing Marc-André Lureau
2020-07-09 19:42 ` [PATCH 11/13] nfs: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 12/13] gluster: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 13/13] ssh: " Marc-André Lureau
2020-07-23 12:31   ` Richard W.M. Jones
2020-07-23 12:58     ` Marc-André Lureau
2020-07-23 13:06       ` Daniel P. Berrangé

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=20200723123004.GO3888@redhat.com \
    --to=rjones@redhat.com \
    --cc=integration@gluster.org \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=namei.unix@gmail.com \
    --cc=pl@kamp.de \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sheepdog@lists.wpkg.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).