summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2023-02-10 11:42:54 +0100
committerAndreas Kling <kling@serenityos.org>2023-02-10 12:15:02 +0100
commit332b253a476ea5a6801230ca8b9fc220764a7cb3 (patch)
treec17629bb4f270453bc94f87cbc12ee2ccdd7f5da /AK
parentbe25602d44fef78ce759f455403eb0546b61817a (diff)
downloadserenity-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.h2
-rw-r--r--AK/Stream.cpp14
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();
}