From 69e55b04e3b97bf425e03b4579d1b51f80f20fb3 Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Thu, 31 Jan 2019 19:42:14 +0100 Subject: [PATCH] suppress openssl-induced SOCKET-to-int warnings on Win64 One is reasonable (a difference between size_t and the type used for a blob in an iovec), the others are SOCKET-to-int conversions that are caused by the openssl API. Since I'm not going to fix openssl and every indication is that the conversion is safe in practice, silencing the compiler is a sensible thing to do. Signed-off-by: Erik Boasson --- src/core/ddsi/src/ddsi_ssl.c | 10 +++++++++- src/core/ddsi/src/ddsi_tcp.c | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/ddsi/src/ddsi_ssl.c b/src/core/ddsi/src/ddsi_ssl.c index ae99a2b..a6b5fdf 100644 --- a/src/core/ddsi/src/ddsi_ssl.c +++ b/src/core/ddsi/src/ddsi_ssl.c @@ -270,9 +270,14 @@ static SSL *ddsi_ssl_connect (os_socket sock) SSL *ssl; int err; - /* Connect SSL over connected socket */ + /* Connect SSL over connected socket; on Win64 a SOCKET is 64-bit type is forced into an int by + the OpenSSL API. Lots of software does use openssl on Win64, so it appears that it is + safe to do so, and moreover, that it will remain safe to do so, given Microsoft's track + record of maintaining backwards compatibility. The SSL API is in the wrong of course ... */ ssl = ddsi_ssl_new (); + OS_WARNING_MSVC_OFF(4244); SSL_set_fd (ssl, sock); + OS_WARNING_MSVC_ON(4244); err = SSL_connect (ssl); if (err != 1) { @@ -286,8 +291,11 @@ static SSL *ddsi_ssl_connect (os_socket sock) static BIO *ddsi_ssl_listen (os_socket sock) { + /* See comment in ddsi_ssl_connect concerning casting the socket to an int */ BIO * bio = BIO_new (BIO_s_accept ()); + OS_WARNING_MSVC_OFF(4244); BIO_set_fd (bio, sock, BIO_NOCLOSE); + OS_WARNING_MSVC_ON(4244); return bio; } diff --git a/src/core/ddsi/src/ddsi_tcp.c b/src/core/ddsi/src/ddsi_tcp.c index 3ec01d9..6ec865c 100644 --- a/src/core/ddsi/src/ddsi_tcp.c +++ b/src/core/ddsi/src/ddsi_tcp.c @@ -602,7 +602,7 @@ static ssize_t ddsi_tcp_conn_write (ddsi_tran_conn_t base, const nn_locator_t *d { int i; char * ptr; - iovec.iov_len = len; + iovec.iov_len = (os_iov_len_t) len; iovec.iov_base = (len <= sizeof (msgbuf)) ? msgbuf : os_malloc (len); ptr = iovec.iov_base; for (i = 0; i < (int) msg.msg_iovlen; i++)