aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2023-11-18 05:31:30 +0000
committerAndy Green <andy@warmcat.com>2023-11-23 09:45:12 +0000
commita1cda263054d865a5d5787c0e2ef32ab1d115891 (patch)
tree9b8914b69affdafbe69a7a91ceb0a9ea9f2d84bf
parenta07699d26973eec85795eebef425212637fc21b9 (diff)
downloadlibwebsockets-a1cda263054d865a5d5787c0e2ef32ab1d115891.tar.gz
windows: evade unused var warnings when logs disabled
https://github.com/warmcat/libwebsockets/pull/2792
-rw-r--r--lib/plat/windows/windows-sockets.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/plat/windows/windows-sockets.c b/lib/plat/windows/windows-sockets.c
index 0099d2f0..455a4ace 100644
--- a/lib/plat/windows/windows-sockets.c
+++ b/lib/plat/windows/windows-sockets.c
@@ -79,11 +79,13 @@ lws_plat_set_nonblocking(lws_sockfd_type fd)
{
u_long optl = 1;
int result = !!ioctlsocket(fd, FIONBIO, &optl);
+#if (_LWS_ENABLED_LOGS & LLL_ERR)
if (result)
{
int error = LWS_ERRNO;
lwsl_err("ioctlsocket FIONBIO 1 failed with error %d\n", error);
}
+#endif
return result;
}
@@ -105,8 +107,10 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd,
optval = 1;
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE,
(const char *)&optval, optlen) < 0) {
+#if (_LWS_ENABLED_LOGS & LLL_ERR)
int error = LWS_ERRNO;
lwsl_err("setsockopt SO_KEEPALIVE 1 failed with error %d\n", error);
+#endif
return 1;
}
@@ -116,8 +120,10 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd,
if (WSAIoctl(fd, SIO_KEEPALIVE_VALS, &alive, sizeof(alive),
NULL, 0, &dwBytesRet, NULL, NULL)) {
+#if (_LWS_ENABLED_LOGS & LLL_ERR)
int error = LWS_ERRNO;
lwsl_err("WSAIoctl SIO_KEEPALIVE_VALS 1 %lu %lu failed with error %d\n", alive.keepalivetime, alive.keepaliveinterval, error);
+#endif
return 1;
}
}
@@ -127,8 +133,10 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd,
#ifndef _WIN32_WCE
tcp_proto = getprotobyname("TCP");
if (!tcp_proto) {
+#if (_LWS_ENABLED_LOGS & LLL_WARN)
int error = LWS_ERRNO;
lwsl_warn("getprotobyname(\"TCP\") failed with error, falling back to 6 %d\n", error);
+#endif
protonbr = 6; /* IPPROTO_TCP */
} else
protonbr = tcp_proto->p_proto;
@@ -137,8 +145,10 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd,
#endif
if (setsockopt(fd, protonbr, TCP_NODELAY, (const char *)&optval, optlen) ) {
+#if (_LWS_ENABLED_LOGS & LLL_WARN)
int error = LWS_ERRNO;
lwsl_warn("setsockopt TCP_NODELAY 1 failed with error %d\n", error);
+#endif
}
return lws_plat_set_nonblocking(fd);
@@ -149,7 +159,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
{
int optval = 1, ret = 0;
socklen_t optlen = sizeof(optval);
-#if !defined(LWS_WITH_NO_LOGS)
+#if (_LWS_ENABLED_LOGS & LLL_WARN)
int en;
#endif
@@ -172,7 +182,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
if (lws_flags & LCCSCF_ALLOW_REUSE_ADDR) {
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
(const void *)&optval, optlen) < 0) {
-#if !defined(LWS_WITH_NO_LOGS)
+#if (_LWS_ENABLED_LOGS & LLL_WARN)
en = errno;
lwsl_warn("%s: unable to reuse local addresses: errno %d\n",
__func__, en);
@@ -184,7 +194,7 @@ lws_plat_set_socket_options_ip(lws_sockfd_type fd, uint8_t pri, int lws_flags)
} else {
if (setsockopt(fd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
(const void *)&optval, optlen) < 0) {
-#if !defined(LWS_WITH_NO_LOGS)
+#if (_LWS_ENABLED_LOGS & LLL_WARN)
en = errno;
lwsl_warn("%s: unable to use exclusive addresses: errno %d\n",
__func__, en);