summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-01 14:35:06 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-01 14:35:06 +0100
commit122c7b6cbbb564a2e06b88a67290aa4fdb6b9749 (patch)
treeaf7352cee4e7278c697e501e1bde237e95cbf2cb /Kernel
parent6a6eb8844a79e317aa87de8c8200b7feb47f8ff9 (diff)
downloadserenity-122c7b6cbbb564a2e06b88a67290aa4fdb6b9749.zip
Kernel: Use Userspace<T> in sys$write()
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.h2
-rw-r--r--Kernel/Syscalls/write.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h
index d663448dd3..9727fba06e 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -242,7 +242,7 @@ public:
KResultOr<int> sys$close(int fd);
KResultOr<ssize_t> sys$read(int fd, Userspace<u8*>, ssize_t);
KResultOr<ssize_t> sys$readv(int fd, Userspace<const struct iovec*> iov, int iov_count);
- KResultOr<ssize_t> sys$write(int fd, const u8*, ssize_t);
+ KResultOr<ssize_t> sys$write(int fd, Userspace<const u8*>, ssize_t);
KResultOr<ssize_t> sys$writev(int fd, Userspace<const struct iovec*> iov, int iov_count);
KResultOr<int> sys$fstat(int fd, Userspace<stat*>);
KResultOr<int> sys$stat(Userspace<const Syscall::SC_stat_params*>);
diff --git a/Kernel/Syscalls/write.cpp b/Kernel/Syscalls/write.cpp
index 82d952e1e0..b5e070522b 100644
--- a/Kernel/Syscalls/write.cpp
+++ b/Kernel/Syscalls/write.cpp
@@ -114,7 +114,7 @@ KResultOr<ssize_t> Process::do_write(FileDescription& description, const UserOrK
return total_nwritten;
}
-KResultOr<ssize_t> Process::sys$write(int fd, const u8* data, ssize_t size)
+KResultOr<ssize_t> Process::sys$write(int fd, Userspace<const u8*> data, ssize_t size)
{
REQUIRE_PROMISE(stdio);
if (size < 0)
@@ -129,7 +129,7 @@ KResultOr<ssize_t> Process::sys$write(int fd, const u8* data, ssize_t size)
if (!description->is_writable())
return EBADF;
- auto buffer = UserOrKernelBuffer::for_user_buffer(const_cast<u8*>(data), (size_t)size);
+ auto buffer = UserOrKernelBuffer::for_user_buffer(data, static_cast<size_t>(size));
if (!buffer.has_value())
return EFAULT;
return do_write(*description, buffer.value(), size);