diff --git a/example/direct_tcpip.c b/example/direct_tcpip.c index 19f77a92..45787286 100644 --- a/example/direct_tcpip.c +++ b/example/direct_tcpip.c @@ -64,7 +64,6 @@ int main(int argc, char *argv[]) LIBSSH2_CHANNEL *channel = NULL; const char *shost; int sport; - fd_set fds; struct timeval tv; ssize_t len, wr; char buf[16384]; @@ -247,8 +246,16 @@ int main(int argc, char *argv[]) libssh2_session_set_blocking(session, 0); for(;;) { + fd_set fds; FD_ZERO(&fds); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(forwardsock, &fds); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif tv.tv_sec = 0; tv.tv_usec = 100000; rc = select((int)(forwardsock + 1), &fds, NULL, NULL, &tv); @@ -256,7 +263,14 @@ int main(int argc, char *argv[]) fprintf(stderr, "failed to select().\n"); goto shutdown; } +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif if(rc && FD_ISSET(forwardsock, &fds)) { +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif len = recv(forwardsock, buf, sizeof(buf), 0); if(len < 0) { fprintf(stderr, "failed to recv().\n"); diff --git a/example/scp_nonblock.c b/example/scp_nonblock.c index 818b2273..4a39546b 100644 --- a/example/scp_nonblock.c +++ b/example/scp_nonblock.c @@ -64,7 +64,14 @@ static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) FD_ZERO(&fd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(socket_fd, &fd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* now make sure we wait in the correct direction */ dir = libssh2_session_block_directions(session); diff --git a/example/scp_write_nonblock.c b/example/scp_write_nonblock.c index 76b02fb7..f3d2b480 100644 --- a/example/scp_write_nonblock.c +++ b/example/scp_write_nonblock.c @@ -48,7 +48,14 @@ static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) FD_ZERO(&fd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(socket_fd, &fd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* now make sure we wait in the correct direction */ dir = libssh2_session_block_directions(session); diff --git a/example/sftp_RW_nonblock.c b/example/sftp_RW_nonblock.c index 94e7aeee..0d994e7d 100644 --- a/example/sftp_RW_nonblock.c +++ b/example/sftp_RW_nonblock.c @@ -56,7 +56,14 @@ static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) FD_ZERO(&fd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(socket_fd, &fd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* now make sure we wait in the correct direction */ dir = libssh2_session_block_directions(session); @@ -251,8 +258,15 @@ int main(int argc, char *argv[]) FD_ZERO(&fd); FD_ZERO(&fd2); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(sock, &fd); FD_SET(sock, &fd2); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* wait for readable or writeable */ rc = select((int)(sock + 1), &fd, &fd2, NULL, &timeout); @@ -316,8 +330,15 @@ int main(int argc, char *argv[]) FD_ZERO(&fd); FD_ZERO(&fd2); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(sock, &fd); FD_SET(sock, &fd2); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* wait for readable or writeable */ rc = select((int)(sock + 1), &fd, &fd2, NULL, &timeout); diff --git a/example/sftp_nonblock.c b/example/sftp_nonblock.c index 795f6a4f..e375bce7 100644 --- a/example/sftp_nonblock.c +++ b/example/sftp_nonblock.c @@ -65,7 +65,14 @@ static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) FD_ZERO(&fd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(socket_fd, &fd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* now make sure we wait in the correct direction */ dir = libssh2_session_block_directions(session); diff --git a/example/sftp_write_nonblock.c b/example/sftp_write_nonblock.c index 4bc27b44..d7671b64 100644 --- a/example/sftp_write_nonblock.c +++ b/example/sftp_write_nonblock.c @@ -54,7 +54,14 @@ static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) FD_ZERO(&fd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(socket_fd, &fd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* now make sure we wait in the correct direction */ dir = libssh2_session_block_directions(session); diff --git a/example/sftp_write_sliding.c b/example/sftp_write_sliding.c index c9f28e30..4390246b 100644 --- a/example/sftp_write_sliding.c +++ b/example/sftp_write_sliding.c @@ -55,7 +55,14 @@ static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) FD_ZERO(&fd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(socket_fd, &fd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* now make sure we wait in the correct direction */ dir = libssh2_session_block_directions(session); diff --git a/example/ssh2_agent_forwarding.c b/example/ssh2_agent_forwarding.c index c58808ed..4d1e9412 100644 --- a/example/ssh2_agent_forwarding.c +++ b/example/ssh2_agent_forwarding.c @@ -50,7 +50,14 @@ static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) FD_ZERO(&fd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(socket_fd, &fd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* now make sure we wait in the correct direction */ dir = libssh2_session_block_directions(session); diff --git a/example/ssh2_echo.c b/example/ssh2_echo.c index dbc07a14..9b45c21a 100644 --- a/example/ssh2_echo.c +++ b/example/ssh2_echo.c @@ -47,7 +47,14 @@ static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) FD_ZERO(&fd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(socket_fd, &fd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* now make sure we wait in the correct direction */ dir = libssh2_session_block_directions(session); diff --git a/example/ssh2_exec.c b/example/ssh2_exec.c index cdd1f4f2..8191210a 100644 --- a/example/ssh2_exec.c +++ b/example/ssh2_exec.c @@ -51,7 +51,14 @@ static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) FD_ZERO(&fd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(socket_fd, &fd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* now make sure we wait in the correct direction */ dir = libssh2_session_block_directions(session); diff --git a/example/tcpip-forward.c b/example/tcpip-forward.c index 4125d308..410988c5 100644 --- a/example/tcpip-forward.c +++ b/example/tcpip-forward.c @@ -66,7 +66,6 @@ int main(int argc, char *argv[]) LIBSSH2_SESSION *session = NULL; LIBSSH2_LISTENER *listener = NULL; LIBSSH2_CHANNEL *channel = NULL; - fd_set fds; struct timeval tv; ssize_t len, wr; char buf[16384]; @@ -245,8 +244,16 @@ int main(int argc, char *argv[]) libssh2_session_set_blocking(session, 0); for(;;) { + fd_set fds; FD_ZERO(&fds); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(forwardsock, &fds); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif tv.tv_sec = 0; tv.tv_usec = 100000; rc = select((int)(forwardsock + 1), &fds, NULL, NULL, &tv); @@ -254,7 +261,14 @@ int main(int argc, char *argv[]) fprintf(stderr, "failed to select().\n"); goto shutdown; } +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif if(rc && FD_ISSET(forwardsock, &fds)) { +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif ssize_t nwritten; len = recv(forwardsock, buf, sizeof(buf), 0); if(len < 0) { diff --git a/example/x11.c b/example/x11.c index 6ae0c982..57f8ee5b 100644 --- a/example/x11.c +++ b/example/x11.c @@ -210,7 +210,14 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, libssh2_socket_t sock) timeval_out.tv_usec = 0; FD_ZERO(&set); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(sock, &set); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif buf = calloc(bufsize, sizeof(char)); if(!buf) @@ -408,7 +415,14 @@ int main(int argc, char *argv[]) for(;;) { FD_ZERO(&set); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(fileno(stdin), &set); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif /* Search if a resize pty has to be send */ ioctl(fileno(stdin), TIOCGWINSZ, &w_size); diff --git a/src/session.c b/src/session.c index 9d89ade8..6053c995 100644 --- a/src/session.c +++ b/src/session.c @@ -674,13 +674,27 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session, time_t start_time) if(dir & LIBSSH2_SESSION_BLOCK_INBOUND) { FD_ZERO(&rfd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(session->socket_fd, &rfd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif readfd = &rfd; } if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND) { FD_ZERO(&wfd); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(session->socket_fd, &wfd); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif writefd = &wfd; } @@ -1635,19 +1649,40 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout) switch(fds[i].type) { case LIBSSH2_POLLFD_SOCKET: if(fds[i].events & LIBSSH2_POLLFD_POLLIN) { +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(fds[i].fd.socket, &rfds); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif if(fds[i].fd.socket > maxfd) maxfd = fds[i].fd.socket; } if(fds[i].events & LIBSSH2_POLLFD_POLLOUT) { +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(fds[i].fd.socket, &wfds); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif if(fds[i].fd.socket > maxfd) maxfd = fds[i].fd.socket; } break; case LIBSSH2_POLLFD_CHANNEL: +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(fds[i].fd.channel->session->socket_fd, &rfds); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif if(fds[i].fd.channel->session->socket_fd > maxfd) maxfd = fds[i].fd.channel->session->socket_fd; if(!session) @@ -1655,7 +1690,14 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout) break; case LIBSSH2_POLLFD_LISTENER: +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif FD_SET(fds[i].fd.listener->session->socket_fd, &rfds); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif if(fds[i].fd.listener->session->socket_fd > maxfd) maxfd = fds[i].fd.listener->session->socket_fd; if(!session) @@ -1832,6 +1874,10 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout) for(i = 0; i < nfds; i++) { switch(fds[i].type) { case LIBSSH2_POLLFD_SOCKET: +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif if(FD_ISSET(fds[i].fd.socket, &rfds)) { fds[i].revents |= LIBSSH2_POLLFD_POLLIN; } @@ -1841,6 +1887,9 @@ libssh2_poll(LIBSSH2_POLLFD * fds, unsigned int nfds, long timeout) if(fds[i].revents) { active_fds++; } +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif break; case LIBSSH2_POLLFD_CHANNEL: