Welcome! Log In Create A New Profile

Advanced

[nginx] Win32: MSVC 2015 compatibility.

Maxim Dounin
August 17, 2015 03:34PM
details: http://hg.nginx.org/nginx/rev/2a621245f4cf
branches:
changeset: 6230:2a621245f4cf
user: Maxim Dounin <mdounin@mdounin.ru>
date: Mon Aug 17 18:09:17 2015 +0300
description:
Win32: MSVC 2015 compatibility.

Resolved warnings about declarations that hide previous local declarations.
Warnings about WSASocketA() being deprecated resolved by explicit use of
WSASocketW() instead of WSASocket(). When compiling without IPv6 support,
WinSock deprecated warnings are disabled to allow use of gethostbyname().

diffstat:

src/http/modules/ngx_http_fastcgi_module.c | 1 -
src/http/modules/ngx_http_map_module.c | 10 +++++-----
src/mail/ngx_mail_core_module.c | 3 +--
src/os/win32/ngx_socket.h | 4 ++--
src/os/win32/ngx_win32_config.h | 5 +++++
src/stream/ngx_stream_core_module.c | 3 +--
src/stream/ngx_stream_proxy_module.c | 10 +++++-----
7 files changed, 19 insertions(+), 17 deletions(-)

diffs (130 lines):

diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -1770,7 +1770,6 @@ ngx_http_fastcgi_process_header(ngx_http
#if (NGX_HTTP_CACHE)

if (f->large_stderr && r->cache) {
- u_char *start;
ssize_t len;
ngx_http_fastcgi_header_t *fh;

diff --git a/src/http/modules/ngx_http_map_module.c b/src/http/modules/ngx_http_map_module.c
--- a/src/http/modules/ngx_http_map_module.c
+++ b/src/http/modules/ngx_http_map_module.c
@@ -375,7 +375,7 @@ ngx_http_map_cmp_dns_wildcards(const voi
static char *
ngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
{
- ngx_int_t rc, index;
+ ngx_int_t rv, index;
ngx_str_t *value, name;
ngx_uint_t i, key;
ngx_http_map_conf_ctx_t *ctx;
@@ -546,19 +546,19 @@ found:
value[0].data++;
}

- rc = ngx_hash_add_key(&ctx->keys, &value[0], var,
+ rv = ngx_hash_add_key(&ctx->keys, &value[0], var,
(ctx->hostnames) ? NGX_HASH_WILDCARD_KEY : 0);

- if (rc == NGX_OK) {
+ if (rv == NGX_OK) {
return NGX_CONF_OK;
}

- if (rc == NGX_DECLINED) {
+ if (rv == NGX_DECLINED) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid hostname or wildcard \"%V\"", &value[0]);
}

- if (rc == NGX_BUSY) {
+ if (rv == NGX_BUSY) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"conflicting parameter \"%V\"", &value[0]);
}
diff --git a/src/mail/ngx_mail_core_module.c b/src/mail/ngx_mail_core_module.c
--- a/src/mail/ngx_mail_core_module.c
+++ b/src/mail/ngx_mail_core_module.c
@@ -434,8 +434,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx

if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) {
#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
- struct sockaddr *sa;
- u_char buf[NGX_SOCKADDR_STRLEN];
+ u_char buf[NGX_SOCKADDR_STRLEN];

sa = &ls->u.sockaddr;

diff --git a/src/os/win32/ngx_socket.h b/src/os/win32/ngx_socket.h
--- a/src/os/win32/ngx_socket.h
+++ b/src/os/win32/ngx_socket.h
@@ -21,9 +21,9 @@ typedef int socklen_t;


#define ngx_socket(af, type, proto) \
- WSASocket(af, type, proto, NULL, 0, WSA_FLAG_OVERLAPPED)
+ WSASocketW(af, type, proto, NULL, 0, WSA_FLAG_OVERLAPPED)

-#define ngx_socket_n "WSASocket()"
+#define ngx_socket_n "WSASocketW()"

int ngx_nonblocking(ngx_socket_t s);
int ngx_blocking(ngx_socket_t s);
diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -21,6 +21,11 @@
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE

+/* enable gethostbyname() in msvc2015 */
+#if !(NGX_HAVE_INET6)
+#define _WINSOCK_DEPRECATED_NO_WARNINGS
+#endif
+
/*
* we need to include <windows.h> explicitly before <winsock2.h> because
* the warning 4201 is enabled in <windows.h>
diff --git a/src/stream/ngx_stream_core_module.c b/src/stream/ngx_stream_core_module.c
--- a/src/stream/ngx_stream_core_module.c
+++ b/src/stream/ngx_stream_core_module.c
@@ -372,8 +372,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, n

if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) {
#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
- struct sockaddr *sa;
- u_char buf[NGX_SOCKADDR_STRLEN];
+ u_char buf[NGX_SOCKADDR_STRLEN];

sa = &ls->u.sockaddr;

diff --git a/src/stream/ngx_stream_proxy_module.c b/src/stream/ngx_stream_proxy_module.c
--- a/src/stream/ngx_stream_proxy_module.c
+++ b/src/stream/ngx_stream_proxy_module.c
@@ -528,18 +528,18 @@ ngx_stream_proxy_init_upstream(ngx_strea
c = s->connection;

if (c->log->log_level >= NGX_LOG_INFO) {
- ngx_str_t s;
+ ngx_str_t str;
u_char addr[NGX_SOCKADDR_STRLEN];

- s.len = NGX_SOCKADDR_STRLEN;
- s.data = addr;
+ str.len = NGX_SOCKADDR_STRLEN;
+ str.data = addr;

- if (ngx_connection_local_sockaddr(pc, &s, 1) == NGX_OK) {
+ if (ngx_connection_local_sockaddr(pc, &str, 1) == NGX_OK) {
handler = c->log->handler;
c->log->handler = NULL;

ngx_log_error(NGX_LOG_INFO, c->log, 0, "proxy %V connected to %V",
- &s, u->peer.name);
+ &str, u->peer.name);

c->log->handler = handler;
}

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Win32: MSVC 2015 compatibility.

Maxim Dounin 772 August 17, 2015 03:34PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 152
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready