}
-static int
-virPCIDriverFile(char **buffer, const char *driver, const char *file)
+static char *
+virPCIDriverFile(const char *driver, const char *file)
{
- VIR_FREE(*buffer);
+ char *buffer;
- if (virAsprintf(buffer, PCI_SYSFS "drivers/%s/%s", driver, file) < 0)
- return -1;
- return 0;
+ ignore_value(virAsprintf(&buffer, PCI_SYSFS "drivers/%s/%s", driver, file));
+ return buffer;
}
goto reprobe;
/* Xen's pciback.ko wants you to use remove_slot on the specific device */
- if (virPCIDriverFile(&path, driver, "remove_slot") < 0)
+ if (!(path = virPCIDriverFile(driver, "remove_slot")))
goto cleanup;
if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
* available, then re-probing would just cause the device to be
* re-bound to the stub.
*/
- if (driver && virPCIDriverFile(&path, driver, "remove_id") < 0)
+ VIR_FREE(path);
+ if (driver && !(path = virPCIDriverFile(driver, "remove_id")))
goto cleanup;
if (!driver || !virFileExists(drvdir) || virFileExists(path)) {
* is triggered for such a device, it will also be immediately
* bound by the stub.
*/
- if (virPCIDriverFile(&path, stubDriverName, "new_id") < 0)
+ if (!(path = virPCIDriverFile(stubDriverName, "new_id")))
goto cleanup;
if (virFileWriteStr(path, dev->id, 0) < 0) {
*/
if (!virFileLinkPointsTo(driverLink, stubDriverPath)) {
/* Xen's pciback.ko wants you to use new_slot first */
- if (virPCIDriverFile(&path, stubDriverName, "new_slot") < 0)
+ VIR_FREE(path);
+ if (!(path = virPCIDriverFile(stubDriverName, "new_slot")))
goto remove_id;
if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
}
dev->remove_slot = true;
- if (virPCIDriverFile(&path, stubDriverName, "bind") < 0)
+ VIR_FREE(path);
+ if (!(path = virPCIDriverFile(stubDriverName, "bind")))
goto remove_id;
if (virFileWriteStr(path, dev->name, 0) < 0) {
/* If 'remove_id' exists, remove the device id from pci-stub's dynamic
* ID table so that 'drivers_probe' works below.
*/
- if (virPCIDriverFile(&path, stubDriverName, "remove_id") < 0) {
+ VIR_FREE(path);
+ if (!(path = virPCIDriverFile(stubDriverName, "remove_id"))) {
/* We do not remove PCI ID from pci-stub, and we cannot reprobe it */
if (dev->reprobe) {
VIR_WARN("Could not remove PCI ID '%s' from %s, and the device "