From 2be60237b04230e35883856c8a37b7746fefeecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 19 Jun 2026 15:30:01 +0200 Subject: [PATCH 1/2] mbedtls: cast sockfd to int when storing in net_context fd The mbedtls server and client bio setup assigned lws_sockfd_type directly to mbedtls_net_context.fd, which is an int. On Win64 lws_sockfd_type is SOCKET (a 64-bit UINT_PTR), so MSVC warns C4244 "possible loss of data", which fails the build under /WX. Add an explicit (int) cast, matching the gnutls and openhitls backends which already cast the same sockfd the same way. --- lib/tls/mbedtls/mbedtls-client.c | 2 +- lib/tls/mbedtls/mbedtls-server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tls/mbedtls/mbedtls-client.c b/lib/tls/mbedtls/mbedtls-client.c index b5f957e99..e0c482cfb 100644 --- a/lib/tls/mbedtls/mbedtls-client.c +++ b/lib/tls/mbedtls/mbedtls-client.c @@ -113,7 +113,7 @@ lws_ssl_client_bio_create(struct lws *wsi) lws_mbedtls_set_alpn(conn->ctx, alpn_comma); } - conn->net.MBEDTLS_PRIVATE_V30_ONLY(fd) = wsi->desc.sockfd; + conn->net.MBEDTLS_PRIVATE_V30_ONLY(fd) = (int)wsi->desc.sockfd; mbedtls_ssl_set_bio(&conn->ssl, &conn->net, lws_plat_mbedtls_net_send, lws_plat_mbedtls_net_recv, NULL); return 0; diff --git a/lib/tls/mbedtls/mbedtls-server.c b/lib/tls/mbedtls/mbedtls-server.c index 9b33e97b0..a24e0fe35 100644 --- a/lib/tls/mbedtls/mbedtls-server.c +++ b/lib/tls/mbedtls/mbedtls-server.c @@ -351,7 +351,7 @@ lws_tls_server_new_nonblocking(struct lws *wsi, lws_sockfd_type accept_fd) return 1; } - conn->net.MBEDTLS_PRIVATE_V30_ONLY(fd) = accept_fd; + conn->net.MBEDTLS_PRIVATE_V30_ONLY(fd) = (int)accept_fd; mbedtls_ssl_set_bio(&conn->ssl, &conn->net, lws_plat_mbedtls_net_send, lws_plat_mbedtls_net_recv, NULL); return 0; From 685531688922b0c64b96340f627d166902b3514b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 19 Jun 2026 15:30:16 +0200 Subject: [PATCH 2/2] cmake: honor DISABLE_WERROR on MSVC DISABLE_WERROR only gated the GCC/Clang -Werror flag; the MSVC branch added /WX unconditionally, so setting DISABLE_WERROR=ON had no effect when building with MSVC. Gate /WX on DISABLE_WERROR the same way the GCC/Clang path does, leaving /W3 (the warning level) always enabled. --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52d397d45..8dccfdf04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1176,8 +1176,13 @@ endif() if (MSVC) # Turn off pointless microsoft security warnings. add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) - # Fail the build if any warnings - add_compile_options(/W3 /WX) + # Fail the build if any warnings, unless DISABLE_WERROR is set (mirrors + # the GCC/Clang -Werror gating above). + if ("${DISABLE_WERROR}" STREQUAL "OFF") + add_compile_options(/W3 /WX) + else() + add_compile_options(/W3) + endif() # Unbreak MSVC broken preprocessor __VA_ARGS__ behaviour if (MSVC_VERSION GREATER 1925) add_compile_options(/Zc:preprocessor /wd5105)