Message ID | 1476522280-23211-5-git-send-email-ashijeetacharya@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 15.10.2016 11:04, Ashijeet Acharya wrote: > Drop the use of legacy options in favour of the InetSocketAddress > options. > > Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com> > --- > block/ssh.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/block/ssh.c b/block/ssh.c > index 6420359..7fec0e1 100644 > --- a/block/ssh.c > +++ b/block/ssh.c > @@ -199,6 +199,7 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) > { > URI *uri = NULL; > QueryParams *qp; > + char *port_str; > int i; > > uri = uri_parse(filename); > @@ -231,11 +232,10 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) > qdict_put(options, "user", qstring_from_str(uri->user)); > } > > - qdict_put(options, "host", qstring_from_str(uri->server)); > + qdict_put(options, "server.host", qstring_from_str(uri->server)); > > - if (uri->port) { > - qdict_put(options, "port", qint_from_int(uri->port)); > - } > + port_str = g_strdup_printf("%d", uri->port ?: 22); > + qdict_put(options, "server.port", qstring_from_str(port_str)); > > qdict_put(options, "path", qstring_from_str(uri->path)); > > @@ -251,6 +251,7 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) > > query_params_free(qp); > uri_free(uri); > + g_free(port_str); I'd put this right after qdict_put(..., qstring_from_str(port_str));. But that's up to you, either way: Reviewed-by: Max Reitz <mreitz@redhat.com> > return 0; > > err: >
diff --git a/block/ssh.c b/block/ssh.c index 6420359..7fec0e1 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -199,6 +199,7 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) { URI *uri = NULL; QueryParams *qp; + char *port_str; int i; uri = uri_parse(filename); @@ -231,11 +232,10 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) qdict_put(options, "user", qstring_from_str(uri->user)); } - qdict_put(options, "host", qstring_from_str(uri->server)); + qdict_put(options, "server.host", qstring_from_str(uri->server)); - if (uri->port) { - qdict_put(options, "port", qint_from_int(uri->port)); - } + port_str = g_strdup_printf("%d", uri->port ?: 22); + qdict_put(options, "server.port", qstring_from_str(port_str)); qdict_put(options, "path", qstring_from_str(uri->path)); @@ -251,6 +251,7 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) query_params_free(qp); uri_free(uri); + g_free(port_str); return 0; err:
Drop the use of legacy options in favour of the InetSocketAddress options. Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com> --- block/ssh.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)