1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:57:44 +00:00

Kernel/Devices/HID: Propagate errors of HIDDevices properly

Some error indication was done by returning bool. This was changed to
propagate the error by ErrorOr from the underlying functions. The
returntype of the underlying functions was also changed to propagate the
error.
This commit is contained in:
Lorenz Steinert 2022-02-23 22:09:39 +01:00 committed by Andreas Kling
parent 83e96569ed
commit d3ce97e8b2
8 changed files with 103 additions and 110 deletions

View file

@ -11,18 +11,16 @@
namespace Kernel {
UNMAP_AFTER_INIT RefPtr<VMWareMouseDevice> VMWareMouseDevice::try_to_initialize(const I8042Controller& ps2_controller)
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<VMWareMouseDevice>> VMWareMouseDevice::try_to_initialize(const I8042Controller& ps2_controller)
{
// FIXME: return the correct error
if (!VMWareBackdoor::the())
return {};
return Error::from_errno(EIO);
if (!VMWareBackdoor::the()->vmmouse_is_absolute())
return {};
auto mouse_device_or_error = DeviceManagement::try_create_device<VMWareMouseDevice>(ps2_controller);
// FIXME: Find a way to propagate errors
VERIFY(!mouse_device_or_error.is_error());
if (mouse_device_or_error.value()->initialize())
return mouse_device_or_error.release_value();
return {};
return Error::from_errno(EIO);
auto mouse_device = TRY(DeviceManagement::try_create_device<VMWareMouseDevice>(ps2_controller));
TRY(mouse_device->initialize());
return mouse_device;
}
void VMWareMouseDevice::irq_handle_byte_read(u8)