From 668c4299000e013852bd07e5df81750db672d607 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Tue, 31 Aug 2021 23:44:55 -0700 Subject: Kernel: Convert UserOrKernelBuffer callbacks to use AK::Bytes --- Kernel/UserOrKernelBuffer.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Kernel/UserOrKernelBuffer.h') diff --git a/Kernel/UserOrKernelBuffer.h b/Kernel/UserOrKernelBuffer.h index 799d8df953..dfc11ee6c4 100644 --- a/Kernel/UserOrKernelBuffer.h +++ b/Kernel/UserOrKernelBuffer.h @@ -89,7 +89,8 @@ public: return EFAULT; if (is_kernel_buffer()) { // We're transferring directly to a kernel buffer, bypass - return f(m_buffer + offset, len); + Bytes bytes { m_buffer + offset, len }; + return f(bytes); } // The purpose of using a buffer on the stack is that we can @@ -98,7 +99,8 @@ public: size_t nwritten = 0; while (nwritten < len) { auto to_copy = min(sizeof(buffer), len - nwritten); - KResultOr copied_or_error = f(buffer, to_copy); + Bytes bytes { buffer, to_copy }; + KResultOr copied_or_error = f(bytes); if (copied_or_error.is_error()) return copied_or_error.error(); auto copied = copied_or_error.value(); @@ -124,7 +126,7 @@ public: return EFAULT; if (is_kernel_buffer()) { // We're transferring directly from a kernel buffer, bypass - return f(m_buffer + offset, len); + return f({ m_buffer + offset, len }); } // The purpose of using a buffer on the stack is that we can @@ -135,7 +137,8 @@ public: auto to_copy = min(sizeof(buffer), len - nread); if (!read(buffer, nread, to_copy)) return EFAULT; - KResultOr copied_or_error = f(buffer, to_copy); + ReadonlyBytes read_only_bytes { buffer, to_copy }; + KResultOr copied_or_error = f(read_only_bytes); if (copied_or_error.is_error()) return copied_or_error.error(); auto copied = copied_or_error.value(); -- cgit v1.2.3