summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-08-17 11:07:15 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-08-17 11:07:15 +0200
commit7127c4fdbb5596659aca2ec3350694341e4d8ee2 (patch)
tree5e394e30ed8b7159cc88a8caac1dd9ee8834c24d
parent910fab564e11547182660b8a04ec32178639b519 (diff)
downloadserenity-7127c4fdbb5596659aca2ec3350694341e4d8ee2.zip
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.
-rw-r--r--Libraries/LibCore/CIODevice.cpp4
-rw-r--r--Libraries/LibCore/CLocalSocket.cpp2
-rw-r--r--Libraries/LibCore/CSocket.cpp2
-rw-r--r--Libraries/LibCore/CTCPSocket.cpp2
4 files changed, 5 insertions, 5 deletions
diff --git a/Libraries/LibCore/CIODevice.cpp b/Libraries/LibCore/CIODevice.cpp
index 8c8fd57a33..0f69fb6cd6 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 53e13e3889..0f7ce785ed 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 f9bfd1b3bf..a6339bedb1 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 4bfe37d4fe..5f5ebb79da 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);