mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +00:00
Only return two values in udevGetStringSysfsAttr
The callers only care for an error, and a missing attribute is simply NULL.
This commit is contained in:
parent
470498de18
commit
e545806db9
@ -149,14 +149,14 @@ static int udevGetStringSysfsAttr(struct udev_device *udev_device,
|
|||||||
char **value)
|
char **value)
|
||||||
{
|
{
|
||||||
if (VIR_STRDUP(*value, udevGetDeviceSysfsAttr(udev_device, attr_name)) < 0)
|
if (VIR_STRDUP(*value, udevGetDeviceSysfsAttr(udev_device, attr_name)) < 0)
|
||||||
return PROPERTY_ERROR;
|
return -1;
|
||||||
|
|
||||||
virStringStripControlChars(*value);
|
virStringStripControlChars(*value);
|
||||||
|
|
||||||
if (*value != NULL && (STREQ(*value, "")))
|
if (*value != NULL && (STREQ(*value, "")))
|
||||||
VIR_FREE(*value);
|
VIR_FREE(*value);
|
||||||
|
|
||||||
return *value == NULL ? PROPERTY_MISSING : PROPERTY_FOUND;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -443,9 +443,8 @@ static int udevProcessUSBDevice(struct udev_device *device,
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!data->usb_dev.vendor_name &&
|
if (!data->usb_dev.vendor_name &&
|
||||||
udevGetStringSysfsAttr(device,
|
udevGetStringSysfsAttr(device, "manufacturer",
|
||||||
"manufacturer",
|
&data->usb_dev.vendor_name) < 0)
|
||||||
&data->usb_dev.vendor_name) == PROPERTY_ERROR)
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (udevGetUintProperty(device, "ID_MODEL_ID", &data->usb_dev.product, 16) < 0)
|
if (udevGetUintProperty(device, "ID_MODEL_ID", &data->usb_dev.product, 16) < 0)
|
||||||
@ -457,9 +456,8 @@ static int udevProcessUSBDevice(struct udev_device *device,
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!data->usb_dev.product_name &&
|
if (!data->usb_dev.product_name &&
|
||||||
udevGetStringSysfsAttr(device,
|
udevGetStringSysfsAttr(device, "product",
|
||||||
"product",
|
&data->usb_dev.product_name) < 0)
|
||||||
&data->usb_dev.product_name) == PROPERTY_ERROR)
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (udevGenerateDeviceName(device, def, NULL) != 0)
|
if (udevGenerateDeviceName(device, def, NULL) != 0)
|
||||||
@ -534,11 +532,9 @@ static int udevProcessNetworkInterface(struct udev_device *device,
|
|||||||
&data->net.ifname) < 0)
|
&data->net.ifname) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (udevGetStringSysfsAttr(device,
|
if (udevGetStringSysfsAttr(device, "address",
|
||||||
"address",
|
&data->net.address) < 0)
|
||||||
&data->net.address) == PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (udevGetUintSysfsAttr(device,
|
if (udevGetUintSysfsAttr(device,
|
||||||
"addr_len",
|
"addr_len",
|
||||||
@ -922,17 +918,11 @@ static int udevProcessStorage(struct udev_device *device,
|
|||||||
if (udevGetStringProperty(device, "ID_SERIAL", &data->storage.serial) < 0)
|
if (udevGetStringProperty(device, "ID_SERIAL", &data->storage.serial) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (udevGetStringSysfsAttr(device,
|
if (udevGetStringSysfsAttr(device, "device/vendor", &data->storage.vendor) < 0)
|
||||||
"device/vendor",
|
|
||||||
&data->storage.vendor) == PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
udevStripSpaces(def->caps->data.storage.vendor);
|
udevStripSpaces(def->caps->data.storage.vendor);
|
||||||
if (udevGetStringSysfsAttr(device,
|
if (udevGetStringSysfsAttr(device, "device/model", &data->storage.model) < 0)
|
||||||
"device/model",
|
|
||||||
&data->storage.model) == PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
udevStripSpaces(def->caps->data.storage.model);
|
udevStripSpaces(def->caps->data.storage.model);
|
||||||
/* There is no equivalent of the hotpluggable property in libudev,
|
/* There is no equivalent of the hotpluggable property in libudev,
|
||||||
* but storage is going toward a world in which hotpluggable is
|
* but storage is going toward a world in which hotpluggable is
|
||||||
@ -1403,51 +1393,31 @@ udevGetDMIData(virNodeDevCapDataPtr data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (udevGetStringSysfsAttr(device,
|
if (udevGetStringSysfsAttr(device, "product_name",
|
||||||
"product_name",
|
&data->system.product_name) < 0)
|
||||||
&data->system.product_name) == PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
if (udevGetStringSysfsAttr(device, "sys_vendor",
|
||||||
if (udevGetStringSysfsAttr(device,
|
&data->system.hardware.vendor_name) < 0)
|
||||||
"sys_vendor",
|
|
||||||
&data->system.hardware.vendor_name)
|
|
||||||
== PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
if (udevGetStringSysfsAttr(device, "product_version",
|
||||||
if (udevGetStringSysfsAttr(device,
|
&data->system.hardware.version) < 0)
|
||||||
"product_version",
|
|
||||||
&data->system.hardware.version)
|
|
||||||
== PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
if (udevGetStringSysfsAttr(device, "product_serial",
|
||||||
if (udevGetStringSysfsAttr(device,
|
&data->system.hardware.serial) < 0)
|
||||||
"product_serial",
|
|
||||||
&data->system.hardware.serial)
|
|
||||||
== PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
if (virGetHostUUID(data->system.hardware.uuid))
|
if (virGetHostUUID(data->system.hardware.uuid))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (udevGetStringSysfsAttr(device,
|
if (udevGetStringSysfsAttr(device, "bios_vendor",
|
||||||
"bios_vendor",
|
&data->system.firmware.vendor_name) < 0)
|
||||||
&data->system.firmware.vendor_name)
|
|
||||||
== PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
if (udevGetStringSysfsAttr(device, "bios_version",
|
||||||
if (udevGetStringSysfsAttr(device,
|
&data->system.firmware.version) < 0)
|
||||||
"bios_version",
|
|
||||||
&data->system.firmware.version)
|
|
||||||
== PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
if (udevGetStringSysfsAttr(device, "bios_date",
|
||||||
if (udevGetStringSysfsAttr(device,
|
&data->system.firmware.release_date) < 0)
|
||||||
"bios_date",
|
|
||||||
&data->system.firmware.release_date)
|
|
||||||
== PROPERTY_ERROR) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (device != NULL)
|
if (device != NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user