summaryrefslogtreecommitdiff
path: root/Kernel/UserOrKernelBuffer.h
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-08-31 23:44:55 -0700
committerAndreas Kling <kling@serenityos.org>2021-09-01 18:06:14 +0200
commit668c4299000e013852bd07e5df81750db672d607 (patch)
treef65ddce4c981fa983a3c54d2de90a3d2c15b8cc4 /Kernel/UserOrKernelBuffer.h
parentf3baa5d8c915285ea109cf12553e497adb7051ca (diff)
downloadserenity-668c4299000e013852bd07e5df81750db672d607.zip
Kernel: Convert UserOrKernelBuffer callbacks to use AK::Bytes
Diffstat (limited to 'Kernel/UserOrKernelBuffer.h')
-rw-r--r--Kernel/UserOrKernelBuffer.h11
1 files changed, 7 insertions, 4 deletions
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<size_t> copied_or_error = f(buffer, to_copy);
+ Bytes bytes { buffer, to_copy };
+ KResultOr<size_t> 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<size_t> copied_or_error = f(buffer, to_copy);
+ ReadonlyBytes read_only_bytes { buffer, to_copy };
+ KResultOr<size_t> copied_or_error = f(read_only_bytes);
if (copied_or_error.is_error())
return copied_or_error.error();
auto copied = copied_or_error.value();