diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-20 23:11:17 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-20 23:20:02 +0100 |
commit | 19d3f8cab77a95b284e30f142521c6b483221324 (patch) | |
tree | 8df3f585e91113215b52d10a9a0032c9998dc1b5 /Kernel/TTY | |
parent | e279b45aed5509efc537fc8c831f40733d7b1028 (diff) | |
download | serenity-19d3f8cab77a95b284e30f142521c6b483221324.zip |
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.
Diffstat (limited to 'Kernel/TTY')
-rw-r--r-- | Kernel/TTY/MasterPTY.cpp | 2 | ||||
-rw-r--r-- | Kernel/TTY/PTYMultiplexer.cpp | 2 | ||||
-rw-r--r-- | Kernel/TTY/TTY.cpp | 6 |
3 files changed, 5 insertions, 5 deletions
diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp index eca9f4c2fa..538b471699 100644 --- a/Kernel/TTY/MasterPTY.cpp +++ b/Kernel/TTY/MasterPTY.cpp @@ -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; } diff --git a/Kernel/TTY/PTYMultiplexer.cpp b/Kernel/TTY/PTYMultiplexer.cpp index 7a9789c544..3ccf768b6d 100644 --- a/Kernel/TTY/PTYMultiplexer.cpp +++ b/Kernel/TTY/PTYMultiplexer.cpp @@ -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 diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp index 4375eef40c..bde26f6da7 100644 --- a/Kernel/TTY/TTY.cpp +++ b/Kernel/TTY/TTY.cpp @@ -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); |