]> git.kaiwu.me - nginx.git/commitdiff
Win32: MSVC 2015 compatibility.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 17 Aug 2015 15:09:17 +0000 (18:09 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 17 Aug 2015 15:09:17 +0000 (18:09 +0300)
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().

src/http/modules/ngx_http_fastcgi_module.c
src/http/modules/ngx_http_map_module.c
src/mail/ngx_mail_core_module.c
src/os/win32/ngx_socket.h
src/os/win32/ngx_win32_config.h
src/stream/ngx_stream_core_module.c
src/stream/ngx_stream_proxy_module.c

index f3f78e804c93be43bac67dee6fddafa4870fe55b..668719fe503832653347ae0f5bebcbfa4abebf70 100644 (file)
@@ -1770,7 +1770,6 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
 #if (NGX_HTTP_CACHE)
 
         if (f->large_stderr && r->cache) {
-            u_char                     *start;
             ssize_t                     len;
             ngx_http_fastcgi_header_t  *fh;
 
index 3245e04132cbb6622cd4ea5f8a48dbd04201e23c..2b80d0f1091e95473f938bb275762ee78dc09e34 100644 (file)
@@ -375,7 +375,7 @@ ngx_http_map_cmp_dns_wildcards(const void *one, const void *two)
 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]);
     }
index 271afc473d1e7a1416358de2dc8817edb05deaa5..c2192961ee8b328a1ea1f72eae12ff5c85cc88ed 100644 (file)
@@ -434,8 +434,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
         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;
 
index f728da2119901e7aaba33e1db8e5d8e94f6770bd..a9e26c2952f53c14a0c60d38f268d50eba769666 100644 (file)
@@ -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);
index 36a486fa85da564bc9280eb89bb56381eb16db7d..f5b5950bb20b255beffc1f4e21c3dc673fe745f1 100644 (file)
 #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>
index b02e5ca5a93bd7391c92ce638a771748a388a9b4..4fe68187e849cfda453e6450b94c15f08ed34553 100644 (file)
@@ -372,8 +372,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
         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;
 
index 1c7877cfd1ac408bab707dea6908246d5d743408..ea142e7224a34ef2d5a8baac0c574e54ffe89ecb 100644 (file)
@@ -528,18 +528,18 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s)
     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;
         }