From: Ján Tomko Date: Fri, 3 Jun 2016 16:04:23 +0000 (+0200) Subject: Fix the return value in udevKludgeStorageType X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=4ccf6886c8efb46bce1d144d01b88e2e3f90ebb1;p=libvirt.git Fix the return value in udevKludgeStorageType Since the switch to VIR_STRDUP this function returns 1 on success, but the caller treats any non-zero value as failure. --- diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 6a3b2a2d6a..0e37bade4c 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -939,28 +939,22 @@ static int udevProcessSD(struct udev_device *device, * storage device it is from other information that is provided. */ static int udevKludgeStorageType(virNodeDeviceDefPtr def) { - int ret = -1; - VIR_DEBUG("Could not find definitive storage type for device " "with sysfs path '%s', trying to guess it", def->sysfs_path); - if (STRPREFIX(def->caps->data.storage.block, "/dev/vd")) { - /* virtio disk */ - ret = VIR_STRDUP(def->caps->data.storage.drive_type, "disk"); - } - - if (ret != 0) { - VIR_DEBUG("Could not determine storage type for device " - "with sysfs path '%s'", def->sysfs_path); - } else { + /* virtio disk */ + if (STRPREFIX(def->caps->data.storage.block, "/dev/vd") && + VIR_STRDUP(def->caps->data.storage.drive_type, "disk") > 0) { VIR_DEBUG("Found storage type '%s' for device " "with sysfs path '%s'", def->caps->data.storage.drive_type, def->sysfs_path); + return 0; } - - return ret; + VIR_DEBUG("Could not determine storage type " + "for device with sysfs path '%s'", def->sysfs_path); + return -1; }