diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-13 09:08:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-13 23:28:40 +0200 |
commit | e46343bf9aadaf8b310821c8a92b131f2b726654 (patch) | |
tree | 4d027e4b413e82b8482865c8a8c3d9b37cdaa0ca /Kernel/Devices/HID | |
parent | 25a45e639ac48bc75507f003c692f24310688e9b (diff) | |
download | serenity-e46343bf9aadaf8b310821c8a92b131f2b726654.zip |
Kernel: Make UserOrKernelBuffer R/W helpers return KResultOr<size_t>
This makes error propagation less cumbersome (and also exposed some
places where we were not doing it.)
Diffstat (limited to 'Kernel/Devices/HID')
-rw-r--r-- | Kernel/Devices/HID/KeyboardDevice.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/Devices/HID/KeyboardDevice.cpp b/Kernel/Devices/HID/KeyboardDevice.cpp index f9e87e4ea7..b49603cbf9 100644 --- a/Kernel/Devices/HID/KeyboardDevice.cpp +++ b/Kernel/Devices/HID/KeyboardDevice.cpp @@ -298,13 +298,13 @@ KResultOr<size_t> KeyboardDevice::read(FileDescription&, u64, UserOrKernelBuffer lock.unlock(); - ssize_t n = buffer.write_buffered<sizeof(Event)>(sizeof(Event), [&](u8* data, size_t data_bytes) { + auto result = buffer.write_buffered<sizeof(Event)>(sizeof(Event), [&](u8* data, size_t data_bytes) { memcpy(data, &event, sizeof(Event)); - return (ssize_t)data_bytes; + return data_bytes; }); - if (n < 0) - return KResult((ErrnoCode)-n); - VERIFY((size_t)n == sizeof(Event)); + if (result.is_error()) + return result.error(); + VERIFY(result.value() == sizeof(Event)); nread += sizeof(Event); lock.lock(); |