summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/write.cpp
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-06-16 16:44:15 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-16 21:29:36 +0200
commitbc3076f8944e5a4f72b15e4e13c16b2c3e2f2080 (patch)
tree95219ba7fb9555dae2876041cc2e30a28556e057 /Kernel/Syscalls/write.cpp
parentca3cae81eb8e20d63e36e7359a776af5eb4d5ea2 (diff)
downloadserenity-bc3076f8944e5a4f72b15e4e13c16b2c3e2f2080.zip
Kernel: Remove various other uses of ssize_t
Diffstat (limited to 'Kernel/Syscalls/write.cpp')
-rw-r--r--Kernel/Syscalls/write.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/Kernel/Syscalls/write.cpp b/Kernel/Syscalls/write.cpp
index 0ba686ca48..88c8217321 100644
--- a/Kernel/Syscalls/write.cpp
+++ b/Kernel/Syscalls/write.cpp
@@ -11,7 +11,7 @@
namespace Kernel {
-KResultOr<ssize_t> Process::sys$writev(int fd, Userspace<const struct iovec*> iov, int iov_count)
+KResultOr<size_t> Process::sys$writev(int fd, Userspace<const struct iovec*> iov, int iov_count)
{
REQUIRE_PROMISE(stdio);
if (iov_count < 0)
@@ -57,9 +57,9 @@ KResultOr<ssize_t> Process::sys$writev(int fd, Userspace<const struct iovec*> io
return nwritten;
}
-KResultOr<ssize_t> Process::do_write(FileDescription& description, const UserOrKernelBuffer& data, size_t data_size)
+KResultOr<size_t> Process::do_write(FileDescription& description, const UserOrKernelBuffer& data, size_t data_size)
{
- ssize_t total_nwritten = 0;
+ size_t total_nwritten = 0;
if (description.should_append() && description.file().is_seekable()) {
auto seek_result = description.seek(0, SEEK_END);
@@ -96,13 +96,13 @@ KResultOr<ssize_t> Process::do_write(FileDescription& description, const UserOrK
return total_nwritten;
}
-KResultOr<ssize_t> Process::sys$write(int fd, Userspace<const u8*> data, ssize_t size)
+KResultOr<size_t> Process::sys$write(int fd, Userspace<const u8*> data, size_t size)
{
REQUIRE_PROMISE(stdio);
- if (size < 0)
- return EINVAL;
if (size == 0)
return 0;
+ if (size > NumericLimits<ssize_t>::max())
+ return EINVAL;
dbgln_if(IO_DEBUG, "sys$write({}, {}, {})", fd, data.ptr(), size);
auto description = file_description(fd);