summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2020-07-03 20:20:00 -0700
committerBart Van Assche <bvanassche@acm.org>2020-07-04 15:59:19 -0700
commit2ec7cd03ea848cf1ae9e7a4be1160b57ec12bd61 (patch)
tree77b2d481d0c47f21bc513f66ed8c8d1206a13e84 /os
parent1e7fa601e884ec37014cfaecab3d4b587f0dd395 (diff)
downloadfio-2ec7cd03ea848cf1ae9e7a4be1160b57ec12bd61.tar.gz
fio-2ec7cd03ea848cf1ae9e7a4be1160b57ec12bd61.tar.bz2
os/windows/posix.c: Use INVALID_SOCKET instead of < 0
From https://docs.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2: "Because the SOCKET type is unsigned, compiling existing source code from, for example, a UNIX environment may lead to compiler warnings about signed/unsigned data type mismatches. This means, for example, that checking for errors when the socket and accept functions return should not be done by comparing the return value with -1, or seeing if the value is negative (both common and legal approaches in UNIX). Instead, an application should use the manifest constant INVALID_SOCKET as defined in the Winsock2.h header file." This patch fixes the following build error for the latest version of the MinGW64 cross-compiler on Cygwin: os/windows/posix.c:886:17: error: comparison of unsigned expression < 0 is always false Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Diffstat (limited to 'os')
-rw-r--r--os/windows/posix.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/os/windows/posix.c b/os/windows/posix.c
index 729d1b1f..31271de0 100644
--- a/os/windows/posix.c
+++ b/os/windows/posix.c
@@ -883,7 +883,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
FD_ZERO(&exceptfds);
for (i = 0; i < nfds; i++) {
- if (fds[i].fd < 0) {
+ if (fds[i].fd == INVALID_SOCKET) {
fds[i].revents = 0;
continue;
}
@@ -900,7 +900,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
if (rc != SOCKET_ERROR) {
for (i = 0; i < nfds; i++) {
- if (fds[i].fd < 0)
+ if (fds[i].fd == INVALID_SOCKET)
continue;
if ((fds[i].events & POLLIN) && FD_ISSET(fds[i].fd, &readfds))