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
Notes: sideshowbarker 2024-07-19 12:39:52 +09:00
4 changed files with 5 additions and 5 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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());

View file

@ -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);