From e46343bf9aadaf8b310821c8a92b131f2b726654 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 13 May 2021 09:08:44 +0200 Subject: Kernel: Make UserOrKernelBuffer R/W helpers return KResultOr This makes error propagation less cumbersome (and also exposed some places where we were not doing it.) --- Kernel/Devices/HID/KeyboardDevice.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Kernel/Devices/HID') 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 KeyboardDevice::read(FileDescription&, u64, UserOrKernelBuffer lock.unlock(); - ssize_t n = buffer.write_buffered(sizeof(Event), [&](u8* data, size_t data_bytes) { + auto result = buffer.write_buffered(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(); -- cgit v1.2.3