[libvirt] [PATCH 39/41] remote: refactor the code for choosing the UNIX socket path

Andrea Bolognani abologna at redhat.com
Mon Jul 29 11:35:12 UTC 2019


On Tue, 2019-07-23 at 17:03 +0100, Daniel P. Berrangé wrote:
[...]
> +++ b/src/remote/remote_driver.c
> @@ -739,34 +739,35 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr conn,
> +static char *
> +remoteGetUNIXSocket(remoteDriverTransport transport,
> +                    unsigned int flags)
>  {
>      char *sockname = NULL;
> -    char *userdir = virGetUserRuntimeDirectory();
> -
> -    if (!userdir)
> -        return NULL;
> +    VIR_AUTOFREE(char *userdir);

This should be

  VIR_AUTOFREE(char *) userdir = NULL;

> @@ -964,6 +965,17 @@ doRemoteOpen(virConnectPtr conn,
> +    if ((transport == REMOTE_DRIVER_TRANSPORT_UNIX ||
> +         transport == REMOTE_DRIVER_TRANSPORT_SSH ||
> +         transport == REMOTE_DRIVER_TRANSPORT_LIBSSH ||
> +         transport == REMOTE_DRIVER_TRANSPORT_LIBSSH2) &&
> +        !sockname &&
> +        !(sockname = remoteGetUNIXSocket(transport, flags)))
> +        goto failed;

The check for transport type should be implemented as a switch
statement for maximum futureproofness.


With at least the "userdir" declaration fixed,

  Reviewed-by: Andrea Bolognani <abologna at redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list