From: Lars Op den Kamp Date: Sat, 11 Feb 2012 01:40:56 +0000 (+0100) Subject: platform: fixed return values of socket operations in lib/platform X-Git-Tag: upstream/2.2.0~1^2~35^2~103 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=15d01ae0b30a685aa5ca07407231dbc7c4ee8e58;p=deb_libcec.git platform: fixed return values of socket operations in lib/platform --- diff --git a/src/lib/platform/posix/os-socket.h b/src/lib/platform/posix/os-socket.h index 30be947..036be3f 100644 --- a/src/lib/platform/posix/os-socket.h +++ b/src/lib/platform/posix/os-socket.h @@ -76,7 +76,7 @@ namespace PLATFORM if (socket == INVALID_SOCKET_VALUE) { *iError = EINVAL; - return -1; + return -EINVAL; } ssize_t iBytesWritten(0); @@ -90,19 +90,19 @@ namespace PLATFORM if (returnv < 0) { *iError = errno; - return -1; + return -errno; } else if (returnv == 0) { *iError = ETIMEDOUT; - return -1; + return -ETIMEDOUT; } returnv = write(socket, (char*)data + iBytesWritten, len - iBytesWritten); if (returnv == -1) { *iError = errno; - return -1; + return -errno; } iBytesWritten += returnv; } @@ -121,7 +121,7 @@ namespace PLATFORM if (socket == INVALID_SOCKET_VALUE) { *iError = EINVAL; - return -1; + return -EINVAL; } if (iTimeoutMs > 0) @@ -150,7 +150,7 @@ namespace PLATFORM if (returnv == -1) { *iError = errno; - return -1; + return -errno; } else if (returnv == 0) { @@ -161,7 +161,7 @@ namespace PLATFORM if (returnv == -1) { *iError = errno; - return -1; + return -errno; } iBytesRead += returnv; @@ -210,7 +210,7 @@ namespace PLATFORM if (socket == INVALID_SOCKET_VALUE) { *iError = EINVAL; - return -1; + return -EINVAL; } if (iTimeoutMs > 0) diff --git a/src/lib/platform/sockets/socket.h b/src/lib/platform/sockets/socket.h index 1d54a03..58a3e3a 100644 --- a/src/lib/platform/sockets/socket.h +++ b/src/lib/platform/sockets/socket.h @@ -163,7 +163,7 @@ namespace PLATFORM virtual ssize_t Write(void* data, size_t len) { if (!m_socket || !WaitReady()) - return EINVAL; + return -EINVAL; ssize_t iReturn = m_socket->Write(data, len); MarkReady(); @@ -174,7 +174,7 @@ namespace PLATFORM virtual ssize_t Read(void* data, size_t len, uint64_t iTimeoutMs = 0) { if (!m_socket || !WaitReady()) - return EINVAL; + return -EINVAL; ssize_t iReturn = m_socket->Read(data, len, iTimeoutMs); MarkReady(); @@ -193,7 +193,7 @@ namespace PLATFORM virtual int GetErrorNumber(void) { CLockObject lock(m_mutex); - return m_socket ? m_socket->GetErrorNumber() : EINVAL; + return m_socket ? m_socket->GetErrorNumber() : -EINVAL; } virtual CStdString GetName(void)