浏览代码

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
Andrew Kaster 3 年之前
父节点
当前提交
7243bcb7da
共有 4 个文件被更改,包括 5 次插入5 次删除
  1. 1 1
      Kernel/FileSystem/InodeFile.cpp
  2. 1 1
      Kernel/Net/IPv4Socket.cpp
  3. 1 1
      Kernel/Net/LocalSocket.cpp
  4. 2 2
      Kernel/Storage/StorageDevice.cpp

+ 1 - 1
Kernel/FileSystem/InodeFile.cpp

@@ -74,7 +74,7 @@ ErrorOr<void> InodeFile::ioctl(OpenFileDescription& description, unsigned reques
     }
     }
     case FIONREAD: {
     case FIONREAD: {
         int remaining_bytes = inode().size() - description.offset();
         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:
     default:
         return EINVAL;
         return EINVAL;

+ 1 - 1
Kernel/Net/IPv4Socket.cpp

@@ -763,7 +763,7 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
 
 
     case FIONREAD: {
     case FIONREAD: {
         int readable = m_receive_buffer->immediately_readable();
         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);
     }
     }
     }
     }
 
 

+ 1 - 1
Kernel/Net/LocalSocket.cpp

@@ -425,7 +425,7 @@ ErrorOr<void> LocalSocket::ioctl(OpenFileDescription& description, unsigned requ
     switch (request) {
     switch (request) {
     case FIONREAD: {
     case FIONREAD: {
         int readable = receive_buffer_for(description)->immediately_readable();
         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);
     }
     }
     }
     }
 
 

+ 2 - 2
Kernel/Storage/StorageDevice.cpp

@@ -193,12 +193,12 @@ ErrorOr<void> StorageDevice::ioctl(OpenFileDescription&, unsigned request, Users
     switch (request) {
     switch (request) {
     case STORAGE_DEVICE_GET_SIZE: {
     case STORAGE_DEVICE_GET_SIZE: {
         size_t disk_size = m_max_addressable_block * block_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;
         break;
     }
     }
     case STORAGE_DEVICE_GET_BLOCK_SIZE: {
     case STORAGE_DEVICE_GET_BLOCK_SIZE: {
         size_t size = 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;
         break;
     }
     }
     default:
     default: