Win32: MinGW GCC compatibility. Several warnings silenced, notably (ngx_socket_t) -1 is now checked on socket operations instead of -1, as ngx_socket_t is unsigned on win32 and gcc complains on comparison. With this patch, it's now possible to compile nginx using mingw gcc, with options we normally compile on win32.
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index e12d3ef..28bf6ba 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c
@@ -297,7 +297,7 @@ continue; } - if (ls[i].fd != -1) { + if (ls[i].fd != (ngx_socket_t) -1) { continue; } @@ -312,7 +312,7 @@ s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, 0); - if (s == -1) { + if (s == (ngx_socket_t) -1) { ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, ngx_socket_n " %V failed", &ls[i].addr_text); return NGX_ERROR; @@ -863,7 +863,7 @@ ngx_uint_t log_error, level; ngx_socket_t fd; - if (c->fd == -1) { + if (c->fd == (ngx_socket_t) -1) { ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed"); return; }
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index 2c006bc..eb39ab2 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c
@@ -543,7 +543,7 @@ } } - if (nls[n].fd == -1) { + if (nls[n].fd == (ngx_socket_t) -1) { nls[n].open = 1; } } @@ -649,7 +649,7 @@ ls = old_cycle->listening.elts; for (i = 0; i < old_cycle->listening.nelts; i++) { - if (ls[i].remain || ls[i].fd == -1) { + if (ls[i].remain || ls[i].fd == (ngx_socket_t) -1) { continue; } @@ -813,7 +813,7 @@ ls = cycle->listening.elts; for (i = 0; i < cycle->listening.nelts; i++) { - if (ls[i].fd == -1 || !ls[i].open) { + if (ls[i].fd == (ngx_socket_t) -1 || !ls[i].open) { continue; }
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c index d59d0c4..d94477a 100644 --- a/src/core/ngx_resolver.c +++ b/src/core/ngx_resolver.c
@@ -2221,7 +2221,7 @@ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, &uc->log, 0, "UDP socket %d", s); - if (s == -1) { + if (s == (ngx_socket_t) -1) { ngx_log_error(NGX_LOG_ALERT, &uc->log, ngx_socket_errno, ngx_socket_n " failed"); return NGX_ERROR;