aboutsummaryrefslogtreecommitdiffstats
path: root/common/rdr/FdOutStream.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2022-11-20 13:25:23 +0100
committerPierre Ossman <ossman@cendio.se>2023-02-04 14:03:13 +0100
commit192a7bec9660663733bf9fcb9038b385fb1187df (patch)
treebba8d7e81104e4d4937937d88cd2cceba0cf19e2 /common/rdr/FdOutStream.cxx
parent03a2057e9eee33eb95a11e1c2a874aec75d30307 (diff)
downloadtigervnc-192a7bec9660663733bf9fcb9038b385fb1187df.tar.gz
tigervnc-192a7bec9660663733bf9fcb9038b385fb1187df.zip
Avoid redefining errno
This can have unexpected consequences as some code may rely on it being a simple variable. Instead to what we do in Socket, which is to define a unique name for getting socket error numbers.
Diffstat (limited to 'common/rdr/FdOutStream.cxx')
-rw-r--r--common/rdr/FdOutStream.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx
index f89fd345..e630a4d7 100644
--- a/common/rdr/FdOutStream.cxx
+++ b/common/rdr/FdOutStream.cxx
@@ -27,8 +27,7 @@
#include <errno.h>
#ifdef _WIN32
#include <winsock2.h>
-#undef errno
-#define errno WSAGetLastError()
+#define errorNumber WSAGetLastError()
#include <os/winerrno.h>
#else
#include <sys/types.h>
@@ -37,6 +36,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#define errorNumber errno
#endif
/* Old systems have select() in sys/time.h */
@@ -109,10 +109,10 @@ size_t FdOutStream::writeFd(const void* data, size_t length)
FD_ZERO(&fds);
FD_SET(fd, &fds);
n = select(fd+1, 0, &fds, 0, &tv);
- } while (n < 0 && errno == EINTR);
+ } while (n < 0 && errorNumber == EINTR);
if (n < 0)
- throw SystemException("select", errno);
+ throw SystemException("select", errorNumber);
if (n == 0)
return 0;
@@ -126,10 +126,10 @@ size_t FdOutStream::writeFd(const void* data, size_t length)
#else
n = ::send(fd, (const char*)data, length, MSG_DONTWAIT);
#endif
- } while (n < 0 && (errno == EINTR));
+ } while (n < 0 && (errorNumber == EINTR));
if (n < 0)
- throw SystemException("write", errno);
+ throw SystemException("write", errorNumber);
gettimeofday(&lastWrite, NULL);