mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
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.
This commit is contained in:
parent
be25602d44
commit
332b253a47
2 changed files with 3 additions and 13 deletions
|
@ -76,11 +76,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
int code() const { return m_code; }
|
int code() const { return m_code; }
|
||||||
#ifndef KERNEL
|
|
||||||
bool is_errno() const
|
bool is_errno() const
|
||||||
{
|
{
|
||||||
return m_code != 0;
|
return m_code != 0;
|
||||||
}
|
}
|
||||||
|
#ifndef KERNEL
|
||||||
bool is_syscall() const
|
bool is_syscall() const
|
||||||
{
|
{
|
||||||
return m_syscall;
|
return m_syscall;
|
||||||
|
|
|
@ -20,15 +20,10 @@ ErrorOr<void> Stream::read_entire_buffer(Bytes buffer)
|
||||||
|
|
||||||
auto result = read(buffer.slice(nread));
|
auto result = read(buffer.slice(nread));
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
#ifdef KERNEL
|
|
||||||
if (result.error().code() == EINTR) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (result.error().is_errno() && result.error().code() == EINTR) {
|
if (result.error().is_errno() && result.error().code() == EINTR) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return result.release_error();
|
return result.release_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,15 +84,10 @@ ErrorOr<void> Stream::write_entire_buffer(ReadonlyBytes buffer)
|
||||||
while (nwritten < buffer.size()) {
|
while (nwritten < buffer.size()) {
|
||||||
auto result = write(buffer.slice(nwritten));
|
auto result = write(buffer.slice(nwritten));
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
#ifdef KERNEL
|
|
||||||
if (result.error().code() == EINTR) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (result.error().is_errno() && result.error().code() == EINTR) {
|
if (result.error().is_errno() && result.error().code() == EINTR) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return result.release_error();
|
return result.release_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue