}
-static int
-virPCIFile(char **buffer, const char *device, const char *file)
+static char *
+virPCIFile(const char *device, const char *file)
{
- VIR_FREE(*buffer);
+ char *buffer;
- if (virAsprintf(buffer, PCI_SYSFS "devices/%s/%s", device, file) < 0)
- return -1;
- return 0;
+ ignore_value(virAsprintf(&buffer, PCI_SYSFS "devices/%s/%s", device, file));
+ return buffer;
}
*path = *name = NULL;
/* drvlink = "/sys/bus/pci/dddd:bb:ss.ff/driver" */
- if (virPCIFile(&drvlink, dev->name, "driver") < 0)
+ if (!(drvlink = virPCIFile(dev->name, "driver")))
goto cleanup;
if (!virFileExists(drvlink)) {
int ret = -1;
unsigned int value;
- if (virPCIFile(&path, dev->name, "class") < 0)
+ if (!(path = virPCIFile(dev->name, "class")))
return ret;
/* class string is '0xNNNNNN\n' ... i.e. 9 bytes */
goto cleanup;
}
- if (virPCIFile(&path, dev->name, "driver/unbind") < 0)
+ if (!(path = virPCIFile(dev->name, "driver/unbind")))
goto cleanup;
if (virFileExists(path)) {
virErrorPtr err = NULL;
if (virPCIDriverDir(&stubDriverPath, stubDriverName) < 0 ||
- virPCIFile(&driverLink, dev->name, "driver") < 0 ||
+ !(driverLink = virPCIFile(dev->name, "driver")) ||
VIR_STRDUP(newDriverName, stubDriverName) < 0)
goto cleanup;
char *path = NULL;
char *id_str;
- if (virPCIFile(&path, dev->name, id_name) < 0)
+ if (!(path = virPCIFile(dev->name, id_name)))
return NULL;
/* ID string is '0xNNNN\n' ... i.e. 7 bytes */
addr->bus, addr->slot, addr->function) < 0)
goto cleanup;
- if (virPCIFile(&devPath, devName, "iommu_group") < 0)
+ if (!(devPath = virPCIFile(devName, "iommu_group")))
goto cleanup;
if (virFileIsLink(devPath) != 1) {
ret = -2;
char *groupPath = NULL;
char *groupDev = NULL;
- if (virPCIFile(&devPath, dev->name, "iommu_group") < 0)
+ if (!(devPath = virPCIFile(dev->name, "iommu_group")))
goto cleanup;
if (virFileIsLink(devPath) != 1) {
virReportError(VIR_ERR_INTERNAL_ERROR,