mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-10 07:20:02 +00:00
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:
parent
0e37f55bb1
commit
a43fb797b5
@ -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,10 @@ 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 +546,10 @@ 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 +600,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 +894,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 +967,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 +1944,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)
|
||||
|
Loading…
Reference in New Issue
Block a user