i386/kvm/pci-assign: Use errp directly rather than local_err

In assigned_device_pci_cap_init(), first, error messages are filled
to a local_err variable, then through error_propagate() pass to
the parameter of errp. It leads to cumbersome code. In order to
avoid the extra local_err and error_propagate(), drop it and use
errp instead.

Cc: pbonzini@redhat.com
Cc: rth@twiddle.net
Cc: ehabkost@redhat.com
Cc: mst@redhat.com
Cc: armbru@redhat.com
Cc: marcel@redhat.com
Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Mao Zhongyi 2017-06-27 14:16:55 +08:00 committed by Michael S. Tsirkin
parent 6b728b3116
commit c0e9067902

View File

@ -1232,7 +1232,6 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
AssignedDevice *dev = PCI_ASSIGN(pci_dev); AssignedDevice *dev = PCI_ASSIGN(pci_dev);
PCIRegion *pci_region = dev->real_device.regions; PCIRegion *pci_region = dev->real_device.regions;
int ret, pos; int ret, pos;
Error *local_err = NULL;
/* Clear initial capabilities pointer and status copied from hw */ /* Clear initial capabilities pointer and status copied from hw */
pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0); pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0);
@ -1251,9 +1250,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI; dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI;
/* Only 32-bit/no-mask currently supported */ /* Only 32-bit/no-mask currently supported */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10, ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, 10,
&local_err); errp);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
pci_dev->msi_cap = pos; pci_dev->msi_cap = pos;
@ -1283,9 +1281,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
dev->dev.cap_present |= QEMU_PCI_CAP_MSIX; dev->dev.cap_present |= QEMU_PCI_CAP_MSIX;
dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX; dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, 12, ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, 12,
&local_err); errp);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
pci_dev->msix_cap = pos; pci_dev->msix_cap = pos;
@ -1313,9 +1310,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
uint16_t pmc; uint16_t pmc;
ret = pci_add_capability(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF, ret = pci_add_capability(pci_dev, PCI_CAP_ID_PM, pos, PCI_PM_SIZEOF,
&local_err); errp);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
@ -1381,9 +1377,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
} }
ret = pci_add_capability(pci_dev, PCI_CAP_ID_EXP, pos, size, ret = pci_add_capability(pci_dev, PCI_CAP_ID_EXP, pos, size,
&local_err); errp);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
@ -1457,9 +1452,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
/* Only expose the minimum, 8 byte capability */ /* Only expose the minimum, 8 byte capability */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_PCIX, pos, 8, ret = pci_add_capability(pci_dev, PCI_CAP_ID_PCIX, pos, 8,
&local_err); errp);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
@ -1485,9 +1479,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
if (pos) { if (pos) {
/* Direct R/W passthrough */ /* Direct R/W passthrough */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_VPD, pos, 8, ret = pci_add_capability(pci_dev, PCI_CAP_ID_VPD, pos, 8,
&local_err); errp);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }
@ -1503,9 +1496,8 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS); uint8_t len = pci_get_byte(pci_dev->config + pos + PCI_CAP_FLAGS);
/* Direct R/W passthrough */ /* Direct R/W passthrough */
ret = pci_add_capability(pci_dev, PCI_CAP_ID_VNDR, pos, len, ret = pci_add_capability(pci_dev, PCI_CAP_ID_VNDR, pos, len,
&local_err); errp);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err);
return ret; return ret;
} }