aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-03-21 22:34:07 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-03-21 22:34:07 +0000
commit8817779f239844a2215b5f1eb7877f0dccd0f857 (patch)
tree65f9e5749ac7d200b56184d1a281c5fc6b6da3ce
parent3e5a32671c234b8c9995aa3085c93d9476d61b01 (diff)
Modified the VALID_SOCK() macro to become VERIFY_SOCK() instead. It is slighly
more involved, but should hopefully not generate any compiler warnings on win32 systems (that can't check the socket based on the numeric).
-rw-r--r--lib/select.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/select.c b/lib/select.c
index 5bd8ea466..7b55138df 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -51,9 +51,15 @@
#include "select.h"
#ifdef WIN32
-#define VALID_SOCK(s) (1) /* Win-sockets are not in range [0..FD_SETSIZE> */
+#define VERIFY_SOCK(x) /* Win-sockets are not in range [0..FD_SETSIZE> */
#else
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
+#define VERIFY_SOCK(x) do { \
+ if(!VALID_SOCK(x)) { \
+ errno = EINVAL; \
+ return -1; \
+ } \
+} while(0)
#endif
/*
@@ -129,10 +135,7 @@ int Curl_select(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms)
FD_ZERO(&fds_read);
if (readfd != CURL_SOCKET_BAD) {
- if (!VALID_SOCK(readfd)) {
- errno = EINVAL;
- return -1;
- }
+ VERIFY_SOCK(readfd);
FD_SET(readfd, &fds_read);
FD_SET(readfd, &fds_err);
maxfd = readfd;
@@ -140,13 +143,10 @@ int Curl_select(curl_socket_t readfd, curl_socket_t writefd, int timeout_ms)
FD_ZERO(&fds_write);
if (writefd != CURL_SOCKET_BAD) {
- if (!VALID_SOCK(writefd)) {
- errno = EINVAL;
- return -1;
- }
+ VERIFY_SOCK(writefd);
FD_SET(writefd, &fds_write);
FD_SET(writefd, &fds_err);
- if (writefd > maxfd)
+ if (writefd > maxfd)s
maxfd = writefd;
}