[libvirt] [PATCH 2/3] tools: remove unnecessary defaultConn variable

Erik Skultety eskultet at redhat.com
Wed Apr 6 11:09:49 UTC 2016


On 06/04/16 10:51, Ján Tomko wrote:
> vshStrdup returns NULL without exiting on NULL input.
> ---
>  tools/virsh.c      | 4 +---
>  tools/virt-admin.c | 4 +---
>  2 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 8c616d6..fe33839 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -908,7 +908,6 @@ main(int argc, char **argv)
>  {
>      vshControl _ctl, *ctl = &_ctl;
>      virshControl virshCtl;
> -    const char *defaultConn;
>      bool ret = true;
>  
>      memset(ctl, 0, sizeof(vshControl));
> @@ -977,8 +976,7 @@ main(int argc, char **argv)
>          exit(EXIT_FAILURE);
>      }
>  
> -    if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI")))
> -        ctl->connname = vshStrdup(ctl, defaultConn);
> +    ctl->connname = vshStrdup(ctl, virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI"));
>  
>      if (!ctl->imode) {
>          ret = vshCommandRun(ctl, ctl->cmd);
> diff --git a/tools/virt-admin.c b/tools/virt-admin.c
> index da847d2..18048d1 100644
> --- a/tools/virt-admin.c
> +++ b/tools/virt-admin.c
> @@ -670,7 +670,6 @@ main(int argc, char **argv)
>  {
>      vshControl _ctl, *ctl = &_ctl;
>      vshAdmControl virtAdminCtl;
> -    const char *defaultConn;
>      bool ret = true;
>  
>      memset(ctl, 0, sizeof(vshControl));
> @@ -728,8 +727,7 @@ main(int argc, char **argv)
>          exit(EXIT_FAILURE);
>      }
>  
> -    if ((defaultConn = virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI")))
> -        ctl->connname = vshStrdup(ctl, defaultConn);
> +    ctl->connname = vshStrdup(ctl, virGetEnvBlockSUID("LIBVIRT_DEFAULT_ADMIN_URI"));
>  
>      if (!ctl->imode) {
>          ret = vshCommandRun(ctl, ctl->cmd);
> 

Like I said in 1/3, if we agree that getting the default connection URI
can be done solely in libvirt-admin library, you don't need the second
bit of the patch. ACK to the virsh part though.

Erik




More information about the libvir-list mailing list