diff options
author | Andrew Kaster <akaster@serenityos.org> | 2021-11-14 15:43:43 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-16 00:13:22 +0100 |
commit | 7243bcb7da80357210db2aaf57094878b5208db0 (patch) | |
tree | eab01970b6b50b023cc97b487a1579b041dcd3f5 /Kernel | |
parent | 194456efdcdeb67c34a9e255385c777ea411b308 (diff) | |
download | serenity-7243bcb7da80357210db2aaf57094878b5208db0.zip |
Kernel: Use static_ptr_cast to convert between Userspace<T*> types
Some calls of copy_to_user were converting Userspace<T*> to
Userspace<U*> via the implicit conversion to FlatPtr. Change them to use
the static_ptr_cast overload that is designed to express this conversion
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/FileSystem/InodeFile.cpp | 2 | ||||
-rw-r--r-- | Kernel/Net/IPv4Socket.cpp | 2 | ||||
-rw-r--r-- | Kernel/Net/LocalSocket.cpp | 2 | ||||
-rw-r--r-- | Kernel/Storage/StorageDevice.cpp | 4 |
4 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp index f72f7ffd12..ad252f1d24 100644 --- a/Kernel/FileSystem/InodeFile.cpp +++ b/Kernel/FileSystem/InodeFile.cpp @@ -74,7 +74,7 @@ ErrorOr<void> InodeFile::ioctl(OpenFileDescription& description, unsigned reques } case FIONREAD: { int remaining_bytes = inode().size() - description.offset(); - return copy_to_user(Userspace<int*>(arg), &remaining_bytes); + return copy_to_user(static_ptr_cast<int*>(arg), &remaining_bytes); } default: return EINVAL; diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index dfb84a474f..e94ca3758b 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -763,7 +763,7 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac case FIONREAD: { int readable = m_receive_buffer->immediately_readable(); - return copy_to_user(Userspace<int*>(arg), &readable); + return copy_to_user(static_ptr_cast<int*>(arg), &readable); } } diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index f7fa1b0620..2fdb923210 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -425,7 +425,7 @@ ErrorOr<void> LocalSocket::ioctl(OpenFileDescription& description, unsigned requ switch (request) { case FIONREAD: { int readable = receive_buffer_for(description)->immediately_readable(); - return copy_to_user(Userspace<int*>(arg), &readable); + return copy_to_user(static_ptr_cast<int*>(arg), &readable); } } diff --git a/Kernel/Storage/StorageDevice.cpp b/Kernel/Storage/StorageDevice.cpp index 1310d57f3f..52e304e005 100644 --- a/Kernel/Storage/StorageDevice.cpp +++ b/Kernel/Storage/StorageDevice.cpp @@ -193,12 +193,12 @@ ErrorOr<void> StorageDevice::ioctl(OpenFileDescription&, unsigned request, Users switch (request) { case STORAGE_DEVICE_GET_SIZE: { size_t disk_size = m_max_addressable_block * block_size(); - return copy_to_user(Userspace<size_t*>(arg), &disk_size); + return copy_to_user(static_ptr_cast<size_t*>(arg), &disk_size); break; } case STORAGE_DEVICE_GET_BLOCK_SIZE: { size_t size = block_size(); - return copy_to_user(Userspace<size_t*>(arg), &size); + return copy_to_user(static_ptr_cast<size_t*>(arg), &size); break; } default: |