Skip to content

Commit

Permalink
Kernel: Remove obsolete size_t casts
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarbeutner authored and awesomekling committed Jun 17, 2021
1 parent 9b14a86 commit bf779e1
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Kernel/FileSystem/Ext2FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ KResultOr<size_t> Ext2FSInode::read_bytes(off_t offset, size_t count, UserOrKern
if (is_symlink() && size() < max_inline_symlink_length) {
VERIFY(offset == 0);
size_t nread = min((off_t)size() - offset, static_cast<off_t>(count));
if (!buffer.write(((const u8*)m_raw_inode.i_block) + offset, (size_t)nread))
if (!buffer.write(((const u8*)m_raw_inode.i_block) + offset, nread))
return EFAULT;
return nread;
}
Expand Down
2 changes: 1 addition & 1 deletion Kernel/FileSystem/Plan9FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ KResultOr<size_t> Plan9FSInode::read_bytes(off_t offset, size_t size, UserOrKern
}

// Guard against the server returning more data than requested.
size_t nread = min(data.length(), (size_t)size);
size_t nread = min(data.length(), size);
if (!buffer.write(data.characters_without_null_termination(), nread))
return EFAULT;

Expand Down
2 changes: 1 addition & 1 deletion Kernel/FileSystem/ProcFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ KResultOr<size_t> ProcFSInode::write_bytes(off_t offset, size_t size, const User
VERIFY(is_persistent_inode(identifier()));
// FIXME: Being able to write into ProcFS at a non-zero offset seems like something we should maybe support..
VERIFY(offset == 0);
auto nwritten_or_error = write_callback(identifier(), buffer, (size_t)size);
auto nwritten_or_error = write_callback(identifier(), buffer, size);
if (nwritten_or_error.is_error())
dbgln("ProcFS: Writing {} bytes failed: {}", size, nwritten_or_error.error());
return nwritten_or_error;
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Syscalls/hostname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ KResultOr<int> Process::sys$gethostname(Userspace<char*> buffer, size_t size)
if (size > NumericLimits<ssize_t>::max())
return EINVAL;
Locker locker(*g_hostname_lock, Lock::Mode::Shared);
if ((size_t)size < (g_hostname->length() + 1))
if (size < (g_hostname->length() + 1))
return ENAMETOOLONG;
if (!copy_to_user(buffer, g_hostname->characters(), g_hostname->length() + 1))
return EFAULT;
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Syscalls/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ KResultOr<int> Process::sys$get_thread_name(pid_t tid, Userspace<char*> buffer,

// We must make a temporary copy here to avoid a race with sys$set_thread_name
auto thread_name = thread->name();
if (thread_name.length() + 1 > (size_t)buffer_size)
if (thread_name.length() + 1 > buffer_size)
return ENAMETOOLONG;

if (!copy_to_user(buffer, thread_name.characters(), thread_name.length() + 1))
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Syscalls/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ KResultOr<size_t> Process::do_write(FileDescription& description, const UserOrKe
return seek_result.error();
}

while ((size_t)total_nwritten < data_size) {
while (total_nwritten < data_size) {
while (!description.can_write()) {
if (!description.is_blocking()) {
if (total_nwritten > 0)
Expand Down
2 changes: 1 addition & 1 deletion Kernel/TTY/VirtualConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ KResultOr<size_t> VirtualConsole::on_tty_write(const UserOrKernelBuffer& data, s
{
ScopedSpinLock global_lock(ConsoleManagement::the().tty_write_lock());
ScopedSpinLock lock(m_lock);
auto result = data.read_buffered<512>((size_t)size, [&](u8 const* buffer, size_t buffer_bytes) {
auto result = data.read_buffered<512>(size, [&](u8 const* buffer, size_t buffer_bytes) {
for (size_t i = 0; i < buffer_bytes; ++i)
m_console_impl.on_input(buffer[i]);
return buffer_bytes;
Expand Down
8 changes: 4 additions & 4 deletions Kernel/UserOrKernelBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ class [[nodiscard]] UserOrKernelBuffer {
if (copied_or_error.is_error())
return copied_or_error.error();
auto copied = copied_or_error.value();
VERIFY((size_t)copied <= to_copy);
if (!write(buffer, nwritten, (size_t)copied))
VERIFY(copied <= to_copy);
if (!write(buffer, nwritten, copied))
return EFAULT;
nwritten += (size_t)copied;
if ((size_t)copied < to_copy)
nwritten += copied;
if (copied < to_copy)
break;
}
return nwritten;
Expand Down

0 comments on commit bf779e1

Please sign in to comment.