summaryrefslogtreecommitdiff
path: root/Kernel/Devices/HID
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-05 17:38:37 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-05 17:38:37 +0200
commit48a0b31c478cb78dece459369610e0f993c8f6f0 (patch)
treef08fde80936619aa94f84edb0973878d8810d147 /Kernel/Devices/HID
parent9903f5c6ef76dfd3c15e63205e307c9519c32ff3 (diff)
downloadserenity-48a0b31c478cb78dece459369610e0f993c8f6f0.zip
Kernel: Make copy_{from,to}_user() return KResult and use TRY()
This makes EFAULT propagation flow much more naturally. :^)
Diffstat (limited to 'Kernel/Devices/HID')
-rw-r--r--Kernel/Devices/HID/KeyboardDevice.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/Kernel/Devices/HID/KeyboardDevice.cpp b/Kernel/Devices/HID/KeyboardDevice.cpp
index 485d5ccbb3..b7b374cc3c 100644
--- a/Kernel/Devices/HID/KeyboardDevice.cpp
+++ b/Kernel/Devices/HID/KeyboardDevice.cpp
@@ -316,9 +316,7 @@ KResult KeyboardDevice::ioctl(FileDescription&, unsigned request, Userspace<void
switch (request) {
case KEYBOARD_IOCTL_GET_NUM_LOCK: {
auto output = static_ptr_cast<bool*>(arg);
- if (!copy_to_user(output, &m_num_lock_on))
- return EFAULT;
- return KSuccess;
+ return copy_to_user(output, &m_num_lock_on);
}
case KEYBOARD_IOCTL_SET_NUM_LOCK: {
// In this case we expect the value to be a boolean and not a pointer.
@@ -330,9 +328,7 @@ KResult KeyboardDevice::ioctl(FileDescription&, unsigned request, Userspace<void
}
case KEYBOARD_IOCTL_GET_CAPS_LOCK: {
auto output = static_ptr_cast<bool*>(arg);
- if (!copy_to_user(output, &m_caps_lock_on))
- return EFAULT;
- return KSuccess;
+ return copy_to_user(output, &m_caps_lock_on);
}
case KEYBOARD_IOCTL_SET_CAPS_LOCK: {
auto caps_lock_value = static_cast<u8>(arg.ptr());