On Wed, Sep 05, 2018 at 10:09:26AM +0200, Andrea Bolognani wrote:
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.
Much
wrapping,
such
narrow
=)
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/util/virnetdev.c | 6 +-----
src/util/virpci.c | 16 ----------------
src/util/virpci.h | 7 -------
3 files changed, 1 insertion(+), 28 deletions(-)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 8eac419725..9cc9d18155 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1305,11 +1305,7 @@ 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) {
+ if (!(pciConfigAddr = virPCIDeviceAddressAsString((*virt_fns)[i]))) {
There is one more thing that this change does, previously it would fail for
non-existing device, which it will not now. I don't think that is a problem,
but wanted to mention that.
virReportSystemError(ENOSYS, "%s",
_("Failed to get PCI Config Address String"));
You should remove this error message as virAsprintf() in
virPCIDeviceAddressAsString() already sets an OOM Error.
I you like working on this function there are lot of things that leak from the
loop, so looking at that would be great, thanks.
With the removal of the error message above:
Reviewed-by: Martin Kletzander <mkletzan(a)redhat.com>