1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 19:27:35 +00:00

Kernel: Remove obsolete size_t casts

This commit is contained in:
Gunnar Beutner 2021-06-17 11:15:55 +02:00 committed by Andreas Kling
parent 9b14a8605a
commit bf779e182e
8 changed files with 11 additions and 11 deletions

View file

@ -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) { if (is_symlink() && size() < max_inline_symlink_length) {
VERIFY(offset == 0); VERIFY(offset == 0);
size_t nread = min((off_t)size() - offset, static_cast<off_t>(count)); 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 EFAULT;
return nread; return nread;
} }

View file

@ -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. // 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)) if (!buffer.write(data.characters_without_null_termination(), nread))
return EFAULT; return EFAULT;

View file

@ -1503,7 +1503,7 @@ KResultOr<size_t> ProcFSInode::write_bytes(off_t offset, size_t size, const User
VERIFY(is_persistent_inode(identifier())); VERIFY(is_persistent_inode(identifier()));
// FIXME: Being able to write into ProcFS at a non-zero offset seems like something we should maybe support.. // FIXME: Being able to write into ProcFS at a non-zero offset seems like something we should maybe support..
VERIFY(offset == 0); 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()) if (nwritten_or_error.is_error())
dbgln("ProcFS: Writing {} bytes failed: {}", size, nwritten_or_error.error()); dbgln("ProcFS: Writing {} bytes failed: {}", size, nwritten_or_error.error());
return nwritten_or_error; return nwritten_or_error;

View file

@ -17,7 +17,7 @@ KResultOr<int> Process::sys$gethostname(Userspace<char*> buffer, size_t size)
if (size > NumericLimits<ssize_t>::max()) if (size > NumericLimits<ssize_t>::max())
return EINVAL; return EINVAL;
Locker locker(*g_hostname_lock, Lock::Mode::Shared); Locker locker(*g_hostname_lock, Lock::Mode::Shared);
if ((size_t)size < (g_hostname->length() + 1)) if (size < (g_hostname->length() + 1))
return ENAMETOOLONG; return ENAMETOOLONG;
if (!copy_to_user(buffer, g_hostname->characters(), g_hostname->length() + 1)) if (!copy_to_user(buffer, g_hostname->characters(), g_hostname->length() + 1))
return EFAULT; return EFAULT;

View file

@ -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 // We must make a temporary copy here to avoid a race with sys$set_thread_name
auto thread_name = 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; return ENAMETOOLONG;
if (!copy_to_user(buffer, thread_name.characters(), thread_name.length() + 1)) if (!copy_to_user(buffer, thread_name.characters(), thread_name.length() + 1))

View file

@ -67,7 +67,7 @@ KResultOr<size_t> Process::do_write(FileDescription& description, const UserOrKe
return seek_result.error(); return seek_result.error();
} }
while ((size_t)total_nwritten < data_size) { while (total_nwritten < data_size) {
while (!description.can_write()) { while (!description.can_write()) {
if (!description.is_blocking()) { if (!description.is_blocking()) {
if (total_nwritten > 0) if (total_nwritten > 0)

View file

@ -269,7 +269,7 @@ KResultOr<size_t> VirtualConsole::on_tty_write(const UserOrKernelBuffer& data, s
{ {
ScopedSpinLock global_lock(ConsoleManagement::the().tty_write_lock()); ScopedSpinLock global_lock(ConsoleManagement::the().tty_write_lock());
ScopedSpinLock lock(m_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) for (size_t i = 0; i < buffer_bytes; ++i)
m_console_impl.on_input(buffer[i]); m_console_impl.on_input(buffer[i]);
return buffer_bytes; return buffer_bytes;

View file

@ -101,11 +101,11 @@ public:
if (copied_or_error.is_error()) if (copied_or_error.is_error())
return copied_or_error.error(); return copied_or_error.error();
auto copied = copied_or_error.value(); auto copied = copied_or_error.value();
VERIFY((size_t)copied <= to_copy); VERIFY(copied <= to_copy);
if (!write(buffer, nwritten, (size_t)copied)) if (!write(buffer, nwritten, copied))
return EFAULT; return EFAULT;
nwritten += (size_t)copied; nwritten += copied;
if ((size_t)copied < to_copy) if (copied < to_copy)
break; break;
} }
return nwritten; return nwritten;