[libvirt] [PATCH v2 3/3] util: Drop virPCIGetAddrString()

Martin Kletzander mkletzan at redhat.com
Wed Sep 5 12:53:02 UTC 2018


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 at 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 at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180905/79c8a15b/attachment-0001.sig>


More information about the libvir-list mailing list