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 <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-01-31 19:42:14 +01:00
parent c5e1c5b2f1
commit 69e55b04e3
2 changed files with 10 additions and 2 deletions

View file

@ -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;
}

View file

@ -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++)