From ca7ad978a96574d904cabe48996dc2b8e1b8bb57 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Tue, 4 Sep 2018 19:05:46 +0200 Subject: [PATCH] util: Drop virPCIGetAddrString() There's a single user for it which takes an existing virPCIDeviceAddress, passes its various bits to the function which in turn constructs a virPCIDevice and then copies the string representation for the caller to use: we can use virPCIDeviceAddressAsString() instead and avoid creating the virPCIDevice in the first place. Since the function ends up having no users after the change, we can just drop it. Signed-off-by: Andrea Bolognani Reviewed-by: Martin Kletzander --- src/util/virnetdev.c | 10 ++-------- src/util/virpci.c | 16 ---------------- src/util/virpci.h | 7 ------- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 8eac419725..c4dd354dc3 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1305,15 +1305,9 @@ virNetDevGetVirtualFunctions(const char *pfname, goto cleanup; for (i = 0; i < *n_vfname; i++) { - if (virPCIGetAddrString((*virt_fns)[i]->domain, - (*virt_fns)[i]->bus, - (*virt_fns)[i]->slot, - (*virt_fns)[i]->function, - &pciConfigAddr) < 0) { - virReportSystemError(ENOSYS, "%s", - _("Failed to get PCI Config Address String")); + if (!(pciConfigAddr = virPCIDeviceAddressAsString((*virt_fns)[i]))) goto cleanup; - } + if (virPCIGetSysfsFile(pciConfigAddr, &pci_sysfs_device_link) < 0) { virReportSystemError(ENOSYS, "%s", _("Failed to get PCI SYSFS file")); diff --git a/src/util/virpci.c b/src/util/virpci.c index d82da710ee..1730d888f7 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1668,22 +1668,6 @@ virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name) return id_str; } -int -virPCIGetAddrString(unsigned int domain, - unsigned int bus, - unsigned int slot, - unsigned int function, - char **pciConfigAddr) -{ - VIR_AUTOPTR(virPCIDevice) dev = NULL; - - dev = virPCIDeviceNew(domain, bus, slot, function); - if (!dev || VIR_STRDUP(*pciConfigAddr, dev->name) < 0) - return -1; - - return 0; -} - char * virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr) { diff --git a/src/util/virpci.h b/src/util/virpci.h index 271a753be2..b4f72f8f06 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -218,13 +218,6 @@ int virPCIGetSysfsFile(char *virPCIDeviceName, char **pci_sysfs_device_link) ATTRIBUTE_RETURN_CHECK; -int virPCIGetAddrString(unsigned int domain, - unsigned int bus, - unsigned int slot, - unsigned int function, - char **pciConfigAddr) - ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK; - char *virPCIDeviceAddressAsString(virPCIDeviceAddressPtr addr) ATTRIBUTE_NONNULL(1);