diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-02-10 11:42:54 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-10 12:15:02 +0100 |
commit | 332b253a476ea5a6801230ca8b9fc220764a7cb3 (patch) | |
tree | c17629bb4f270453bc94f87cbc12ee2ccdd7f5da /AK | |
parent | be25602d44fef78ce759f455403eb0546b61817a (diff) | |
download | serenity-332b253a476ea5a6801230ca8b9fc220764a7cb3.zip |
AK: Provide `is_errno` for Kernel Errors
It wouldn't make much sense on its own (as the Kernel only has errno
Errors), but it's an easy fix for not having to ifdef away every single
usage of `is_errno` in code that is shared between Userland and Kernel.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Error.h | 2 | ||||
-rw-r--r-- | AK/Stream.cpp | 14 |
2 files changed, 3 insertions, 13 deletions
diff --git a/AK/Error.h b/AK/Error.h index 302de1cf3c..02eccaf5ca 100644 --- a/AK/Error.h +++ b/AK/Error.h @@ -76,11 +76,11 @@ public: } int code() const { return m_code; } -#ifndef KERNEL bool is_errno() const { return m_code != 0; } +#ifndef KERNEL bool is_syscall() const { return m_syscall; diff --git a/AK/Stream.cpp b/AK/Stream.cpp index 2b0ae90da2..c47afe3dbf 100644 --- a/AK/Stream.cpp +++ b/AK/Stream.cpp @@ -20,15 +20,10 @@ ErrorOr<void> Stream::read_entire_buffer(Bytes buffer) auto result = read(buffer.slice(nread)); if (result.is_error()) { -#ifdef KERNEL - if (result.error().code() == EINTR) { - continue; - } -#else if (result.error().is_errno() && result.error().code() == EINTR) { continue; } -#endif + return result.release_error(); } @@ -89,15 +84,10 @@ ErrorOr<void> Stream::write_entire_buffer(ReadonlyBytes buffer) while (nwritten < buffer.size()) { auto result = write(buffer.slice(nwritten)); if (result.is_error()) { -#ifdef KERNEL - if (result.error().code() == EINTR) { - continue; - } -#else if (result.error().is_errno() && result.error().code() == EINTR) { continue; } -#endif + return result.release_error(); } |