[PATCH 3/9] util: simplify virPCIDriverDir() and its callers

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

 



There is no need for a temporary variable in this function, and since
it can't return NULL, no need for callers to check for it.

Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
---
 src/util/virpci.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 0786ddd478..ac37a60576 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -209,10 +209,7 @@ VIR_ONCE_GLOBAL_INIT(virPCI);
 static char *
 virPCIDriverDir(const char *driver)
 {
-    char *buffer;
-
-    buffer = g_strdup_printf(PCI_SYSFS "drivers/%s", driver);
-    return buffer;
+    return g_strdup_printf(PCI_SYSFS "drivers/%s", driver);
 }
 
 
@@ -1002,7 +999,9 @@ virPCIProbeStubDriver(virPCIStubDriver driver)
     }
 
  recheck:
-    if ((drvpath = virPCIDriverDir(drvname)) && virFileExists(drvpath))
+    drvpath = virPCIDriverDir(drvname);
+
+    if (virFileExists(drvpath))
         /* driver already loaded, return */
         return 0;
 
@@ -1153,9 +1152,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev)
         return -1;
     }
 
-    if (!(stubDriverPath = virPCIDriverDir(stubDriverName)))
-        return -1;
-
+    stubDriverPath = virPCIDriverDir(stubDriverName);
     driverLink = virPCIFile(dev->name, "driver");
 
     if (virFileExists(driverLink)) {
-- 
2.26.2




[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]

  Powered by Linux