From 7127c4fdbb5596659aca2ec3350694341e4d8ee2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 17 Aug 2019 11:07:15 +0200 Subject: [PATCH] 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. --- Libraries/LibCore/CIODevice.cpp | 4 ++-- Libraries/LibCore/CLocalSocket.cpp | 2 +- Libraries/LibCore/CSocket.cpp | 2 +- Libraries/LibCore/CTCPSocket.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/LibCore/CIODevice.cpp b/Libraries/LibCore/CIODevice.cpp index 8c8fd57a33f..0f69fb6cd69 100644 --- a/Libraries/LibCore/CIODevice.cpp +++ b/Libraries/LibCore/CIODevice.cpp @@ -126,7 +126,7 @@ ByteBuffer CIODevice::read_all() char read_buffer[4096]; int nread = ::read(m_fd, read_buffer, sizeof(read_buffer)); if (nread < 0) { - set_error(nread); + set_error(errno); return ByteBuffer::copy(data.data(), data.size()); } if (nread == 0) { @@ -196,7 +196,7 @@ bool CIODevice::close() return false; int rc = ::close(fd()); if (rc < 0) { - set_error(rc); + set_error(errno); return false; } set_fd(-1); diff --git a/Libraries/LibCore/CLocalSocket.cpp b/Libraries/LibCore/CLocalSocket.cpp index 53e13e38898..0f7ce785ed9 100644 --- a/Libraries/LibCore/CLocalSocket.cpp +++ b/Libraries/LibCore/CLocalSocket.cpp @@ -15,7 +15,7 @@ CLocalSocket::CLocalSocket(CObject* parent) { int fd = socket(AF_LOCAL, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); if (fd < 0) { - set_error(fd); + set_error(errno); } else { set_fd(fd); set_mode(CIODevice::ReadWrite); diff --git a/Libraries/LibCore/CSocket.cpp b/Libraries/LibCore/CSocket.cpp index f9bfd1b3bfe..a6339bedb15 100644 --- a/Libraries/LibCore/CSocket.cpp +++ b/Libraries/LibCore/CSocket.cpp @@ -125,7 +125,7 @@ bool CSocket::send(const ByteBuffer& data) { int nsent = ::send(fd(), data.pointer(), data.size(), 0); if (nsent < 0) { - set_error(nsent); + set_error(errno); return false; } ASSERT(nsent == data.size()); diff --git a/Libraries/LibCore/CTCPSocket.cpp b/Libraries/LibCore/CTCPSocket.cpp index 4bfe37d4fe1..5f5ebb79da3 100644 --- a/Libraries/LibCore/CTCPSocket.cpp +++ b/Libraries/LibCore/CTCPSocket.cpp @@ -15,7 +15,7 @@ CTCPSocket::CTCPSocket(CObject* parent) { int fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); if (fd < 0) { - set_error(fd); + set_error(errno); } else { set_fd(fd); set_mode(CIODevice::ReadWrite);