]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
util: Resolve Coverity FORWARD_NULL
authorJohn Ferlan <jferlan@redhat.com>
Tue, 30 Jun 2015 19:53:53 +0000 (15:53 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 1 Jul 2015 16:15:16 +0000 (12:15 -0400)
Convert virPCIDriverDir to return the buffer allocated (or not) and make the
appropriate check in the caller.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/util/virpci.c

index 28cee9d9b0602657297a04375ddfd0f56ac2b20b..35b145931a88059c3a83fc9152763a6b520bbbff 100644 (file)
@@ -204,14 +204,13 @@ static int virPCIOnceInit(void)
 VIR_ONCE_GLOBAL_INIT(virPCI)
 
 
-static int
-virPCIDriverDir(char **buffer, const char *driver)
+static char *
+virPCIDriverDir(const char *driver)
 {
-    VIR_FREE(*buffer);
+    char *buffer;
 
-    if (virAsprintf(buffer, PCI_SYSFS "drivers/%s", driver) < 0)
-        return -1;
-    return 0;
+    ignore_value(virAsprintf(&buffer, PCI_SYSFS "drivers/%s", driver));
+    return buffer;
 }
 
 
@@ -998,7 +997,7 @@ virPCIProbeStubDriver(const char *driver)
     bool probed = false;
 
  recheck:
-    if (virPCIDriverDir(&drvpath, driver) == 0 && virFileExists(drvpath)) {
+    if ((drvpath = virPCIDriverDir(driver)) && virFileExists(drvpath)) {
         /* driver already loaded, return */
         VIR_FREE(drvpath);
         return 0;
@@ -1188,7 +1187,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
     char *newDriverName = NULL;
     virErrorPtr err = NULL;
 
-    if (virPCIDriverDir(&stubDriverPath, stubDriverName) < 0 ||
+    if (!(stubDriverPath = virPCIDriverDir(stubDriverName))  ||
         !(driverLink = virPCIFile(dev->name, "driver")) ||
         VIR_STRDUP(newDriverName, stubDriverName) < 0)
         goto cleanup;