[libvirt] [PATCH v6 08/13] qemu: Add zPCI address definition check

Andrea Bolognani abologna at redhat.com
Thu Oct 11 12:44:41 UTC 2018


On Fri, 2018-09-28 at 16:46 +0800, Yi Min Zhao wrote:
[...]
> +static int
> +qemuDomainDeviceDefValidateAddress(const virDomainDeviceDef *dev,
> +                                   virQEMUCapsPtr qemuCaps)
> +{
> +    virDomainDeviceInfoPtr info =
> +        virDomainDeviceGetInfo((virDomainDeviceDef *)dev);
> +
> +    if (!info)
> +        return 0;

Using

  virDomainDeviceInfoPtr info;

  if (!(info = virDomainDeviceGetInfo((virDomainDeviceDef *)dev)))
    return 0;

here would look much better.

[...]
> @@ -5811,6 +5844,10 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
>                                              def->emulator)))
>          return -1;
>  
> +    ret = qemuDomainDeviceDefValidateAddress(dev, qemuCaps);
> +    if (ret < 0)
> +        goto out;

This could be

  if ((ret = qemuDomainDeviceDefValidateAddress(dev, qemuCaps)) < 0)
      ...

[...]
> @@ -5886,6 +5923,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
>          break;
>      }
>  
> + out:
>      virObjectUnref(qemuCaps);
>      return ret;

'cleanup' would be a more appropriate name for the label since
you're releasing resources when you reach it.


With the above addressed,

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

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list