udevGetStringSysfsAttr() return value is invariant, so change it type and remove all dependent checks. Fixes: 7f1f0453fc ("node_device: use g_strdup instead of VIR_STRDUP") Signed-off-by: Artem Chernyshev <artem.chernyshev@xxxxxxxxxxx> --- src/node_device/node_device_udev.c | 55 +++++++++--------------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 8d38aec070..b610bc9c16 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -245,7 +245,7 @@ udevGetDeviceSysfsAttr(struct udev_device *udev_device, } -static int +static void udevGetStringSysfsAttr(struct udev_device *udev_device, const char *attr_name, char **value) @@ -256,8 +256,6 @@ udevGetStringSysfsAttr(struct udev_device *udev_device, if (*value != NULL && (STREQ(*value, ""))) VIR_FREE(*value); - - return 0; } @@ -536,10 +534,9 @@ udevProcessUSBDevice(struct udev_device *device, "ID_VENDOR_FROM_DATABASE", &usb_dev->vendor_name); - if (!usb_dev->vendor_name && + if (!usb_dev->vendor_name) udevGetStringSysfsAttr(device, "manufacturer", - &usb_dev->vendor_name) < 0) - return -1; + &usb_dev->vendor_name); if (udevGetUintProperty(device, "ID_MODEL_ID", &usb_dev->product, 16) < 0) return -1; @@ -548,10 +545,9 @@ udevProcessUSBDevice(struct udev_device *device, "ID_MODEL_FROM_DATABASE", &usb_dev->product_name); - if (!usb_dev->product_name && + if (!usb_dev->product_name) udevGetStringSysfsAttr(device, "product", - &usb_dev->product_name) < 0) - return -1; + &usb_dev->product_name); udevGenerateDeviceName(device, def, NULL); @@ -602,9 +598,7 @@ udevProcessNetworkInterface(struct udev_device *device, udevGetStringProperty(device, "INTERFACE", &net->ifname); - if (udevGetStringSysfsAttr(device, "address", - &net->address) < 0) - return -1; + udevGetStringSysfsAttr(device, "address", &net->address); if (udevGetUintSysfsAttr(device, "addr_len", &net->address_len, 0) < 0) return -1; @@ -898,8 +892,7 @@ udevProcessDASD(struct udev_device *device, { virNodeDevCapStorage *storage = &def->caps->data.storage; - if (udevGetStringSysfsAttr(device, "device/uid", &storage->serial) < 0) - return -1; + udevGetStringSysfsAttr(device, "device/uid", &storage->serial); return udevProcessDisk(device, def); } @@ -972,13 +965,11 @@ udevProcessStorage(struct udev_device *device, udevGetStringProperty(device, "ID_BUS", &storage->bus); udevGetStringProperty(device, "ID_SERIAL", &storage->serial); - if (udevGetStringSysfsAttr(device, "device/vendor", &storage->vendor) < 0) - goto cleanup; + udevGetStringSysfsAttr(device, "device/vendor", &storage->vendor); if (def->caps->data.storage.vendor) virTrimSpaces(def->caps->data.storage.vendor, NULL); - if (udevGetStringSysfsAttr(device, "device/model", &storage->model) < 0) - goto cleanup; + udevGetStringSysfsAttr(device, "device/model", &storage->model); if (def->caps->data.storage.model) virTrimSpaces(def->caps->data.storage.model, NULL); /* There is no equivalent of the hotpluggable property in libudev, @@ -1951,31 +1942,17 @@ udevGetDMIData(virNodeDevCapSystem *syscap) } } - if (udevGetStringSysfsAttr(device, "product_name", - &syscap->product_name) < 0) - goto cleanup; - if (udevGetStringSysfsAttr(device, "sys_vendor", - &hardware->vendor_name) < 0) - goto cleanup; - if (udevGetStringSysfsAttr(device, "product_version", - &hardware->version) < 0) - goto cleanup; - if (udevGetStringSysfsAttr(device, "product_serial", - &hardware->serial) < 0) - goto cleanup; + udevGetStringSysfsAttr(device, "product_name", &syscap->product_name); + udevGetStringSysfsAttr(device, "sys_vendor", &hardware->vendor_name); + udevGetStringSysfsAttr(device, "product_version", &hardware->version); + udevGetStringSysfsAttr(device, "product_serial", &hardware->serial); if (virGetHostUUID(hardware->uuid)) goto cleanup; - if (udevGetStringSysfsAttr(device, "bios_vendor", - &firmware->vendor_name) < 0) - goto cleanup; - if (udevGetStringSysfsAttr(device, "bios_version", - &firmware->version) < 0) - goto cleanup; - if (udevGetStringSysfsAttr(device, "bios_date", - &firmware->release_date) < 0) - goto cleanup; + udevGetStringSysfsAttr(device, "bios_vendor", &firmware->vendor_name); + udevGetStringSysfsAttr(device, "bios_version", &firmware->version); + udevGetStringSysfsAttr(device, "bios_date", &firmware->release_date); cleanup: if (device != NULL) -- 2.43.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx