mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
util: Resolve Coverity FORWARD_NULL
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>
This commit is contained in:
parent
e3939e86ba
commit
c50c664de5
@ -204,14 +204,13 @@ static int virPCIOnceInit(void)
|
|||||||
VIR_ONCE_GLOBAL_INIT(virPCI)
|
VIR_ONCE_GLOBAL_INIT(virPCI)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static char *
|
||||||
virPCIDriverDir(char **buffer, const char *driver)
|
virPCIDriverDir(const char *driver)
|
||||||
{
|
{
|
||||||
VIR_FREE(*buffer);
|
char *buffer;
|
||||||
|
|
||||||
if (virAsprintf(buffer, PCI_SYSFS "drivers/%s", driver) < 0)
|
ignore_value(virAsprintf(&buffer, PCI_SYSFS "drivers/%s", driver));
|
||||||
return -1;
|
return buffer;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -998,7 +997,7 @@ virPCIProbeStubDriver(const char *driver)
|
|||||||
bool probed = false;
|
bool probed = false;
|
||||||
|
|
||||||
recheck:
|
recheck:
|
||||||
if (virPCIDriverDir(&drvpath, driver) == 0 && virFileExists(drvpath)) {
|
if ((drvpath = virPCIDriverDir(driver)) && virFileExists(drvpath)) {
|
||||||
/* driver already loaded, return */
|
/* driver already loaded, return */
|
||||||
VIR_FREE(drvpath);
|
VIR_FREE(drvpath);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1188,7 +1187,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
|
|||||||
char *newDriverName = NULL;
|
char *newDriverName = NULL;
|
||||||
virErrorPtr err = NULL;
|
virErrorPtr err = NULL;
|
||||||
|
|
||||||
if (virPCIDriverDir(&stubDriverPath, stubDriverName) < 0 ||
|
if (!(stubDriverPath = virPCIDriverDir(stubDriverName)) ||
|
||||||
!(driverLink = virPCIFile(dev->name, "driver")) ||
|
!(driverLink = virPCIFile(dev->name, "driver")) ||
|
||||||
VIR_STRDUP(newDriverName, stubDriverName) < 0)
|
VIR_STRDUP(newDriverName, stubDriverName) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user