node_device: udevGetStringSysfsAttr() to void

udevGetStringSysfsAttr() return value is invariant, so change it
type and remove all dependent checks.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Artem Chernyshev 2024-01-04 03:17:03 +03:00 committed by Michal Privoznik
parent 0e37f55bb1
commit a43fb797b5

View File

@ -245,7 +245,7 @@ udevGetDeviceSysfsAttr(struct udev_device *udev_device,
} }
static int static void
udevGetStringSysfsAttr(struct udev_device *udev_device, udevGetStringSysfsAttr(struct udev_device *udev_device,
const char *attr_name, const char *attr_name,
char **value) char **value)
@ -256,8 +256,6 @@ udevGetStringSysfsAttr(struct udev_device *udev_device,
if (*value != NULL && (STREQ(*value, ""))) if (*value != NULL && (STREQ(*value, "")))
VIR_FREE(*value); VIR_FREE(*value);
return 0;
} }
@ -536,10 +534,10 @@ udevProcessUSBDevice(struct udev_device *device,
"ID_VENDOR_FROM_DATABASE", "ID_VENDOR_FROM_DATABASE",
&usb_dev->vendor_name); &usb_dev->vendor_name);
if (!usb_dev->vendor_name && if (!usb_dev->vendor_name) {
udevGetStringSysfsAttr(device, "manufacturer", udevGetStringSysfsAttr(device, "manufacturer",
&usb_dev->vendor_name) < 0) &usb_dev->vendor_name);
return -1; }
if (udevGetUintProperty(device, "ID_MODEL_ID", &usb_dev->product, 16) < 0) if (udevGetUintProperty(device, "ID_MODEL_ID", &usb_dev->product, 16) < 0)
return -1; return -1;
@ -548,10 +546,10 @@ udevProcessUSBDevice(struct udev_device *device,
"ID_MODEL_FROM_DATABASE", "ID_MODEL_FROM_DATABASE",
&usb_dev->product_name); &usb_dev->product_name);
if (!usb_dev->product_name && if (!usb_dev->product_name) {
udevGetStringSysfsAttr(device, "product", udevGetStringSysfsAttr(device, "product",
&usb_dev->product_name) < 0) &usb_dev->product_name);
return -1; }
udevGenerateDeviceName(device, def, NULL); udevGenerateDeviceName(device, def, NULL);
@ -602,9 +600,7 @@ udevProcessNetworkInterface(struct udev_device *device,
udevGetStringProperty(device, "INTERFACE", &net->ifname); udevGetStringProperty(device, "INTERFACE", &net->ifname);
if (udevGetStringSysfsAttr(device, "address", udevGetStringSysfsAttr(device, "address", &net->address);
&net->address) < 0)
return -1;
if (udevGetUintSysfsAttr(device, "addr_len", &net->address_len, 0) < 0) if (udevGetUintSysfsAttr(device, "addr_len", &net->address_len, 0) < 0)
return -1; return -1;
@ -898,8 +894,7 @@ udevProcessDASD(struct udev_device *device,
{ {
virNodeDevCapStorage *storage = &def->caps->data.storage; virNodeDevCapStorage *storage = &def->caps->data.storage;
if (udevGetStringSysfsAttr(device, "device/uid", &storage->serial) < 0) udevGetStringSysfsAttr(device, "device/uid", &storage->serial);
return -1;
return udevProcessDisk(device, def); return udevProcessDisk(device, def);
} }
@ -972,13 +967,11 @@ udevProcessStorage(struct udev_device *device,
udevGetStringProperty(device, "ID_BUS", &storage->bus); udevGetStringProperty(device, "ID_BUS", &storage->bus);
udevGetStringProperty(device, "ID_SERIAL", &storage->serial); udevGetStringProperty(device, "ID_SERIAL", &storage->serial);
if (udevGetStringSysfsAttr(device, "device/vendor", &storage->vendor) < 0) udevGetStringSysfsAttr(device, "device/vendor", &storage->vendor);
goto cleanup;
if (def->caps->data.storage.vendor) if (def->caps->data.storage.vendor)
virTrimSpaces(def->caps->data.storage.vendor, NULL); virTrimSpaces(def->caps->data.storage.vendor, NULL);
if (udevGetStringSysfsAttr(device, "device/model", &storage->model) < 0) udevGetStringSysfsAttr(device, "device/model", &storage->model);
goto cleanup;
if (def->caps->data.storage.model) if (def->caps->data.storage.model)
virTrimSpaces(def->caps->data.storage.model, NULL); virTrimSpaces(def->caps->data.storage.model, NULL);
/* There is no equivalent of the hotpluggable property in libudev, /* There is no equivalent of the hotpluggable property in libudev,
@ -1951,31 +1944,17 @@ udevGetDMIData(virNodeDevCapSystem *syscap)
} }
} }
if (udevGetStringSysfsAttr(device, "product_name", udevGetStringSysfsAttr(device, "product_name", &syscap->product_name);
&syscap->product_name) < 0) udevGetStringSysfsAttr(device, "sys_vendor", &hardware->vendor_name);
goto cleanup; udevGetStringSysfsAttr(device, "product_version", &hardware->version);
if (udevGetStringSysfsAttr(device, "sys_vendor", udevGetStringSysfsAttr(device, "product_serial", &hardware->serial);
&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;
if (virGetHostUUID(hardware->uuid)) if (virGetHostUUID(hardware->uuid))
goto cleanup; goto cleanup;
if (udevGetStringSysfsAttr(device, "bios_vendor", udevGetStringSysfsAttr(device, "bios_vendor", &firmware->vendor_name);
&firmware->vendor_name) < 0) udevGetStringSysfsAttr(device, "bios_version", &firmware->version);
goto cleanup; udevGetStringSysfsAttr(device, "bios_date", &firmware->release_date);
if (udevGetStringSysfsAttr(device, "bios_version",
&firmware->version) < 0)
goto cleanup;
if (udevGetStringSysfsAttr(device, "bios_date",
&firmware->release_date) < 0)
goto cleanup;
cleanup: cleanup:
if (device != NULL) if (device != NULL)