Skip to content

Commit 332b253

Browse files
timschumiawesomekling
authored andcommitted
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.
1 parent be25602 commit 332b253

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

AK/Error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ class Error {
7676
}
7777

7878
int code() const { return m_code; }
79-
#ifndef KERNEL
8079
bool is_errno() const
8180
{
8281
return m_code != 0;
8382
}
83+
#ifndef KERNEL
8484
bool is_syscall() const
8585
{
8686
return m_syscall;

AK/Stream.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,10 @@ ErrorOr<void> Stream::read_entire_buffer(Bytes buffer)
2020

2121
auto result = read(buffer.slice(nread));
2222
if (result.is_error()) {
23-
#ifdef KERNEL
24-
if (result.error().code() == EINTR) {
25-
continue;
26-
}
27-
#else
2823
if (result.error().is_errno() && result.error().code() == EINTR) {
2924
continue;
3025
}
31-
#endif
26+
3227
return result.release_error();
3328
}
3429

@@ -89,15 +84,10 @@ ErrorOr<void> Stream::write_entire_buffer(ReadonlyBytes buffer)
8984
while (nwritten < buffer.size()) {
9085
auto result = write(buffer.slice(nwritten));
9186
if (result.is_error()) {
92-
#ifdef KERNEL
93-
if (result.error().code() == EINTR) {
94-
continue;
95-
}
96-
#else
9787
if (result.error().is_errno() && result.error().code() == EINTR) {
9888
continue;
9989
}
100-
#endif
90+
10191
return result.release_error();
10292
}
10393

0 commit comments

Comments
 (0)