1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 00:57:43 +00:00

LibCore: CIODevice::set_error() is meant to be called with the 'errno'

The point of this function is to stash away the innermost error code
so that we don't lose it by the time we get back to the client code.
This commit is contained in:
Andreas Kling 2019-08-17 11:07:15 +02:00
parent 910fab564e
commit 7127c4fdbb
4 changed files with 5 additions and 5 deletions

View file

@ -126,7 +126,7 @@ ByteBuffer CIODevice::read_all()
char read_buffer[4096]; char read_buffer[4096];
int nread = ::read(m_fd, read_buffer, sizeof(read_buffer)); int nread = ::read(m_fd, read_buffer, sizeof(read_buffer));
if (nread < 0) { if (nread < 0) {
set_error(nread); set_error(errno);
return ByteBuffer::copy(data.data(), data.size()); return ByteBuffer::copy(data.data(), data.size());
} }
if (nread == 0) { if (nread == 0) {
@ -196,7 +196,7 @@ bool CIODevice::close()
return false; return false;
int rc = ::close(fd()); int rc = ::close(fd());
if (rc < 0) { if (rc < 0) {
set_error(rc); set_error(errno);
return false; return false;
} }
set_fd(-1); set_fd(-1);

View file

@ -15,7 +15,7 @@ CLocalSocket::CLocalSocket(CObject* parent)
{ {
int fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); int fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
if (fd < 0) { if (fd < 0) {
set_error(fd); set_error(errno);
} else { } else {
set_fd(fd); set_fd(fd);
set_mode(CIODevice::ReadWrite); set_mode(CIODevice::ReadWrite);

View file

@ -125,7 +125,7 @@ bool CSocket::send(const ByteBuffer& data)
{ {
int nsent = ::send(fd(), data.pointer(), data.size(), 0); int nsent = ::send(fd(), data.pointer(), data.size(), 0);
if (nsent < 0) { if (nsent < 0) {
set_error(nsent); set_error(errno);
return false; return false;
} }
ASSERT(nsent == data.size()); ASSERT(nsent == data.size());

View file

@ -15,7 +15,7 @@ CTCPSocket::CTCPSocket(CObject* parent)
{ {
int fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); int fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (fd < 0) { if (fd < 0) {
set_error(fd); set_error(errno);
} else { } else {
set_fd(fd); set_fd(fd);
set_mode(CIODevice::ReadWrite); set_mode(CIODevice::ReadWrite);