1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

util: simplify virPCIDriverDir() and its callers

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>
This commit is contained in:
Laine Stump 2020-10-10 17:50:11 -04:00
parent 862f7e5c73
commit b3066b55bf

View 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)) {