aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libssh/libssh.h8
-rw-r--r--libssh/poll.c4
2 files changed, 8 insertions, 4 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 4100f03..cf1c9d6 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -120,10 +120,14 @@ typedef struct ssh_string_struct* ssh_string;
/* Socket type */
#ifdef _WIN32
-#define socket_t SOCKET
-#else
+#ifndef socket_t
+typedef SOCKET socket_t;
+#endif /* socket_t */
+#else /* _WIN32 */
+#ifndef socket_t
typedef int socket_t;
#endif
+#endif /* _WIN32 */
/* the offsets of methods */
enum ssh_kex_types_e {
diff --git a/libssh/poll.c b/libssh/poll.c
index 5eb80aa..f6a8174 100644
--- a/libssh/poll.c
+++ b/libssh/poll.c
@@ -135,7 +135,7 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
FD_ZERO (&exceptfds);
/* compute fd_sets and find largest descriptor */
- for (max_fd = -1, i = 0; i < nfds; i++) {
+ for (max_fd = 0, i = 0; i < nfds; i++) {
if (fds[i].fd < 0) {
continue;
}
@@ -157,7 +157,7 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
}
}
- if (max_fd == -1) {
+ if (max_fd == (socket_t) -1) {
errno = EINVAL;
return -1;
}