]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: simplify virPCIDriverDir() and its callers
authorLaine Stump <laine@redhat.com>
Sat, 10 Oct 2020 21:50:11 +0000 (17:50 -0400)
committerLaine Stump <laine@redhat.com>
Wed, 21 Oct 2020 19:15:00 +0000 (15:15 -0400)
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@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/util/virpci.c

index 0786ddd4780f4783692e5cf36c1f0bd27dadb889..ac37a60576a98dfe8f05377db73f52bef75f596d 100644 (file)
@@ -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)) {