[PATCH 1/6] pci: Remove redundant parameter from virPCIDeviceBindToStub()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This internal function supports, in theory, binding to a different
stub driver than the one the PCI device has been configured to use.

In practice, it is only ever called like

  virPCIDeviceBindToStub(dev, dev->stubDriver);

which makes its second parameter redundant. Get rid of it, along
with the extra string copy required to support it.
---
 src/util/virpci.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 6f0cb8c..424983d 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1177,20 +1177,18 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
 
 
 static int
-virPCIDeviceBindToStub(virPCIDevicePtr dev,
-                       const char *stubDriverName)
+virPCIDeviceBindToStub(virPCIDevicePtr dev)
 {
     int result = -1;
     bool reprobe = false;
     char *stubDriverPath = NULL;
     char *driverLink = NULL;
     char *path = NULL; /* reused for different purposes */
-    char *newDriverName = NULL;
+    char *stubDriverName = dev->stubDriver;
     virErrorPtr err = NULL;
 
     if (!(stubDriverPath = virPCIDriverDir(stubDriverName))  ||
-        !(driverLink = virPCIFile(dev->name, "driver")) ||
-        VIR_STRDUP(newDriverName, stubDriverName) < 0)
+        !(driverLink = virPCIFile(dev->name, "driver")))
         goto cleanup;
 
     if (virFileExists(driverLink)) {
@@ -1305,13 +1303,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
     VIR_FREE(driverLink);
     VIR_FREE(path);
 
-    if (result < 0) {
-        VIR_FREE(newDriverName);
+    if (result < 0)
         virPCIDeviceUnbindFromStub(dev);
-    } else {
-        VIR_FREE(dev->stubDriver);
-        dev->stubDriver = newDriverName;
-    }
 
     if (err)
         virSetError(err);
@@ -1354,7 +1347,7 @@ virPCIDeviceDetach(virPCIDevicePtr dev,
         return -1;
     }
 
-    if (virPCIDeviceBindToStub(dev, dev->stubDriver) < 0)
+    if (virPCIDeviceBindToStub(dev) < 0)
         return -1;
 
     /* Add *a copy of* the dev into list inactiveDevs, if
-- 
2.5.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]