Re: [PATCH 2/2] qemu: Check return status for virDomainGraphicsListenSetAddress

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

 



On Tue, Feb 09, 2016 at 07:34:02AM -0500, John Ferlan wrote:
> Recent refactors in the vbox code to check the return status for the
> function tipped Coverity's scales of justice for any functions that
> do not check status - such as this one.
> 
> Add a check of the status, adjust the long line too.
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  src/qemu/qemu_command.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 7b5a36f..a0ff5d4 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -13135,12 +13135,17 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
>                                     _("cannot parse VNC port '%s'"), port);
>                      goto error;
>                  }
> -                if (val[0] == '[')
> -                    virDomainGraphicsListenSetAddress(vnc, 0,
> -                                                      val+1, tmp-(val+1), true);
> -                else
> -                    virDomainGraphicsListenSetAddress(vnc, 0,
> -                                                      val, tmp-val, true);
> +                if (val[0] == '[') {
> +                    if (virDomainGraphicsListenSetAddress(vnc, 0,
> +                                                          val+1, tmp-(val+1),
> +                                                          true) < 0)
> +                        goto error;
> +                } else {
> +                    if (virDomainGraphicsListenSetAddress(vnc, 0,
> +                                                          val, tmp-val,
> +                                                          true) < 0)
> +                        goto error;
> +                }

>                  if (!virDomainGraphicsListenGetAddress(vnc, 0))
>                      goto error;

This call looks redundant after we start checking the return value.

Looking at commit ef79fb5b5 [1] which introduced this, the code was:

  if (val[0] == '[')
    vnc->data.vnc.listenAddr = strndup(val+1, tmp-(val+1));
  else
    vnc->data.vnc.listenAddr = strndup(val, tmp-val);
  if (!vnc->data.vnc.listenAddr) {
    VIR_FREE(vnc);
    goto no_memory;
  }
so it's just a leftover from strndup -> ListenSetAddress conversion.

Jan

[1] http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=ef79fb5b5

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]