Re: [PATCH spice-gtk v2 3/4] uri: generate spice://host:port or spice+tls://host:port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> Hi
> 
> On Wed, Feb 21, 2018 at 5:53 PM, Marc-André Lureau
> <marcandre.lureau@xxxxxxxxx> wrote:
> > On Wed, Feb 21, 2018 at 10:17 AM, Frediano Ziglio <fziglio@xxxxxxxxxx>
> > wrote:
> >>> From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
> >>>
> >>> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
> >>> ---
> >>>  src/spice-session.c | 31 +++++++++++++++++++++++--------
> >>>  tests/session.c     | 20 ++++++++++----------
> >>>  2 files changed, 33 insertions(+), 18 deletions(-)
> >>>
> >>> diff --git a/src/spice-session.c b/src/spice-session.c
> >>> index d2aa5e7..6faf0f2 100644
> >>> --- a/src/spice-session.c
> >>> +++ b/src/spice-session.c
> >>> @@ -400,17 +400,32 @@ static gchar* spice_uri_create(SpiceSession
> >>> *session)
> >>>      if (s->unix_path != NULL) {
> >>>          return g_strdup_printf(URI_SCHEME_SPICE_UNIX "%s",
> >>>          s->unix_path);
> >>>      } else if (s->host != NULL) {
> >>> +        GString *str;
> >>>          g_return_val_if_fail(s->port != NULL || s->tls_port != NULL,
> >>>          NULL);
> >>>
> >>> -        GString *str = g_string_new(URI_SCHEME_SPICE);
> >>> +        if (!!s->tls_port + !!s->port == 1) {
> >>> +            /* use spice://foo:4390 or spice+tls://.. form */
> >>> +            const char *port;
> >>>
> >>> -        g_string_append(str, s->host);
> >>> -        g_string_append(str, "?");
> >>> -        if (s->port != NULL) {
> >>> -            g_string_append_printf(str, "port=%s&", s->port);
> >>> -        }
> >>> -        if (s->tls_port != NULL) {
> >>> -            g_string_append_printf(str, "tls-port=%s", s->tls_port);
> >>> +            if (s->tls_port) {
> >>> +                str = g_string_new(URI_SCHEME_SPICE_TLS);
> >>> +                port = s->tls_port;
> >>> +            } else {
> >>> +                str = g_string_new(URI_SCHEME_SPICE);
> >>> +                port = s->port;
> >>> +            }
> >>> +            g_string_append_printf(str, "%s:%s", s->host, port);
> >>> +        } else {
> >>> +            /* use spice://foo?port=4390&tls-port= form */
> >>> +            str = g_string_new(URI_SCHEME_SPICE);
> >>> +            g_string_append(str, s->host);
> >>> +            g_string_append(str, "?");
> >>> +            if (s->port != NULL) {
> >>> +                g_string_append_printf(str, "port=%s&", s->port);
> >>> +            }
> >>> +            if (s->tls_port != NULL) {
> >>> +                g_string_append_printf(str, "tls-port=%s", s->tls_port);
> >>> +            }
> >>>          }
> >>>          return g_string_free(str, FALSE);
> >>>      }
> >>
> >> Looks more complicated than should be, specially the !!s->tls_port +
> >> !!s->port == 1
> >> check. Considered that the row above remove the case where none are set
> >> the check can just be if both are set and the reverse, I propose (tested)
> >> a
> >>
> >>
> >
> > Indeed, thanks for the suggestion!
> 
> ack with your changes, or would you like me to resend the pending patches?
> 

Fine, merged, was going to ask but either you or me seems busy.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]