在 2018/10/11 下午8:44, Andrea Bolognani 写道:
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(a)redhat.com>
Thanks! Will update the code as your comments.
--
Yi Min