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

Kernel+LibC: Turn errno codes into a strongly typed enum

..and allow implicit creation of KResult and KResultOr from ErrnoCode.
This means that kernel functions that return those types can finally
do "return EINVAL;" and it will just work.

There's a handful of functions that still deal with signed integers
that should be converted to return KResults.
This commit is contained in:
Andreas Kling 2021-01-20 23:11:17 +01:00
parent e279b45aed
commit 19d3f8cab7
48 changed files with 591 additions and 506 deletions

View file

@ -75,7 +75,7 @@ KResultOr<size_t> MasterPTY::read(FileDescription&, size_t, UserOrKernelBuffer&
KResultOr<size_t> MasterPTY::write(FileDescription&, size_t, const UserOrKernelBuffer& buffer, size_t size)
{
if (!m_slave)
return KResult(-EIO);
return EIO;
m_slave->on_master_write(buffer, size);
return size;
}

View file

@ -59,7 +59,7 @@ KResultOr<NonnullRefPtr<FileDescription>> PTYMultiplexer::open(int options)
{
LOCKER(m_lock);
if (m_freelist.is_empty())
return KResult(-EBUSY);
return EBUSY;
auto master_index = m_freelist.take_last();
auto master = adopt(*new MasterPTY(master_index));
#ifdef PTMX_DEBUG

View file

@ -58,7 +58,7 @@ KResultOr<size_t> TTY::read(FileDescription&, size_t, UserOrKernelBuffer& buffer
if (Process::current()->pgid() != pgid()) {
// FIXME: Should we propagate this error path somehow?
[[maybe_unused]] auto rc = Process::current()->send_signal(SIGTTIN, nullptr);
return KResult(-EINTR);
return EINTR;
}
if (m_input_buffer.size() < static_cast<size_t>(size))
@ -95,7 +95,7 @@ KResultOr<size_t> TTY::read(FileDescription&, size_t, UserOrKernelBuffer& buffer
});
}
if (nwritten < 0)
return KResult(nwritten);
return KResult((ErrnoCode)-nwritten);
if (nwritten > 0 || need_evaluate_block_conditions)
evaluate_block_conditions();
return (size_t)nwritten;
@ -105,7 +105,7 @@ KResultOr<size_t> TTY::write(FileDescription&, size_t, const UserOrKernelBuffer&
{
if (m_termios.c_lflag & TOSTOP && Process::current()->pgid() != pgid()) {
[[maybe_unused]] auto rc = Process::current()->send_signal(SIGTTOU, nullptr);
return KResult(-EINTR);
return EINTR;
}
on_tty_write(buffer, size);