]> git.kaiwu.me - nginx.git/commitdiff
Win32: Borland C compatibility fixes.
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 4 Sep 2013 16:48:23 +0000 (20:48 +0400)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 4 Sep 2013 16:48:23 +0000 (20:48 +0400)
Several false positive warnings silenced, notably W8012 "Comparing
signed and unsigned" (due to u_short values promoted to int), and
W8072 "Suspicious pointer arithmetic" (due to large type values added
to pointers).

With this patch, it's now again possible to compile nginx using bcc32,
with options we normally compile on win32 minus ipv6 and ssl.

auto/lib/pcre/makefile.bcc
src/event/ngx_event_accept.c
src/http/modules/ngx_http_memcached_module.c
src/http/modules/ngx_http_mp4_module.c
src/http/modules/ngx_http_proxy_module.c
src/http/modules/ngx_http_upstream_ip_hash_module.c
src/http/ngx_http_file_cache.c
src/http/ngx_http_request_body.c
src/os/win32/ngx_win32_config.h

index 7230f32053345579bd3668a2410182505a898fb7..7a0f2beafc6ac92410790cf56df8d91e53ecb8d8 100644 (file)
@@ -13,8 +13,8 @@ pcre.lib:
 
        bcc32 -c $(CFLAGS) -I. $(PCREFLAGS) pcre_*.c
 
-       > pcre.lst
-       for %n in (*.obj) do @echo +%n & >> pcre.lst
+       copy /y nul pcre.lst
+       for %n in (*.obj) do @echo +%n ^^& >> pcre.lst
        echo + >> pcre.lst
 
        tlib pcre.lib @pcre.lst
index e3f828da88465af8a544d16ec7f787b5530f820b..6f571f1a861713ded8f6cc74cb66192006987bff 100644 (file)
@@ -297,7 +297,7 @@ ngx_event_accept(ngx_event_t *ev)
 
         cidr = ecf->debug_connection.elts;
         for (i = 0; i < ecf->debug_connection.nelts; i++) {
-            if (cidr[i].family != c->sockaddr->sa_family) {
+            if (cidr[i].family != (ngx_uint_t) c->sockaddr->sa_family) {
                 goto next;
             }
 
index bfff1bfc26bb8e67fb3c7f8557e27b78351e8ead..aaa047e8fb79de0b59877cc3b8378f284a830591 100644 (file)
@@ -520,7 +520,7 @@ ngx_http_memcached_filter(void *data, ssize_t bytes)
         return NGX_OK;
     }
 
-    last += u->length - NGX_HTTP_MEMCACHED_END;
+    last += (size_t) (u->length - NGX_HTTP_MEMCACHED_END);
 
     if (ngx_strncmp(last, ngx_http_memcached_end, b->last - last) != 0) {
         ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0,
index 680b6587105484269fd4a8b827286c01a593359e..c44dc52c9bdc4fd43e63d6ebf947e4a58e2984cf 100644 (file)
@@ -157,7 +157,11 @@ typedef struct {
 #define ngx_mp4_atom_header(mp4)   (mp4->buffer_pos - 8)
 #define ngx_mp4_atom_data(mp4)     mp4->buffer_pos
 #define ngx_mp4_atom_data_size(t)  (uint64_t) (sizeof(t) - 8)
-#define ngx_mp4_atom_next(mp4, n)  mp4->buffer_pos += n; mp4->offset += n
+
+
+#define ngx_mp4_atom_next(mp4, n)                                             \
+    mp4->buffer_pos += (size_t) n;                                            \
+    mp4->offset += n
 
 
 #define ngx_mp4_set_atom_name(p, n1, n2, n3, n4)                              \
@@ -956,7 +960,7 @@ ngx_http_mp4_read_ftyp_atom(ngx_http_mp4_file_t *mp4, uint64_t atom_data_size)
     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, mp4->file.log, 0, "mp4 ftyp atom");
 
     if (atom_data_size > 1024
-        || ngx_mp4_atom_data(mp4) + atom_data_size > mp4->buffer_end)
+        || ngx_mp4_atom_data(mp4) + (size_t) atom_data_size > mp4->buffer_end)
     {
         ngx_log_error(NGX_LOG_ERR, mp4->file.log, 0,
                       "\"%s\" mp4 ftyp atom is too large:%uL",
@@ -1304,7 +1308,7 @@ ngx_http_mp4_read_trak_atom(ngx_http_mp4_file_t *mp4, uint64_t atom_data_size)
 
     trak->out[NGX_HTTP_MP4_TRAK_ATOM].buf = atom;
 
-    atom_end = mp4->buffer_pos + atom_data_size;
+    atom_end = mp4->buffer_pos + (size_t) atom_data_size;
     atom_file_end = mp4->offset + atom_data_size;
 
     rc = ngx_http_mp4_read_atom(mp4, ngx_http_mp4_trak_atoms, atom_data_size);
index a22ed0fcb9d6113575f5204f28d453362e867aae..f5fd83d141f8f590899c6213aff3fab10a7bb4e3 100644 (file)
@@ -1712,7 +1712,7 @@ ngx_http_proxy_chunked_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
 
             if (buf->last - buf->pos >= ctx->chunked.size) {
 
-                buf->pos += ctx->chunked.size;
+                buf->pos += (size_t) ctx->chunked.size;
                 b->last = buf->pos;
                 ctx->chunked.size = 0;
 
@@ -1875,7 +1875,7 @@ ngx_http_proxy_non_buffered_chunked_filter(void *data, ssize_t bytes)
             b->tag = u->output.tag;
 
             if (buf->last - buf->pos >= ctx->chunked.size) {
-                buf->pos += ctx->chunked.size;
+                buf->pos += (size_t) ctx->chunked.size;
                 b->last = buf->pos;
                 ctx->chunked.size = 0;
 
index 29c74fd54d0a3ff303a814d953c12f47c66ef8c1..0e5cf416af6f97c0ddc98c4514e87690f01d440f 100644 (file)
@@ -174,7 +174,7 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data)
 
     for ( ;; ) {
 
-        for (i = 0; i < iphp->addrlen; i++) {
+        for (i = 0; i < (ngx_uint_t) iphp->addrlen; i++) {
             hash = (hash * 113 + iphp->addr[i]) % 6271;
         }
 
index cf27683e6dc7a5653e4c0a8aa7c2f6b8bc0f62d9..7e46d1295935eac8510729a2a9ade7366e1404e0 100644 (file)
@@ -503,7 +503,7 @@ ngx_http_file_cache_read(ngx_http_request_t *r, ngx_http_cache_t *c)
         return NGX_DECLINED;
     }
 
-    if (h->body_start > c->body_start) {
+    if ((size_t) h->body_start > c->body_start) {
         ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
                       "cache file \"%s\" has too long header",
                       c->file.name.data);
index fc3a1800df03f29f143538ce9bce0f5eb5287bc4..dc1fcde1c9edf5f4de50a258d843fc7188bf6f89 100644 (file)
@@ -714,7 +714,7 @@ ngx_http_discard_request_body_filter(ngx_http_request_t *r, ngx_buf_t *b)
                 size = b->last - b->pos;
 
                 if ((off_t) size > rb->chunked->size) {
-                    b->pos += rb->chunked->size;
+                    b->pos += (size_t) rb->chunked->size;
                     rb->chunked->size = 0;
 
                 } else {
@@ -753,7 +753,7 @@ ngx_http_discard_request_body_filter(ngx_http_request_t *r, ngx_buf_t *b)
         size = b->last - b->pos;
 
         if ((off_t) size > r->headers_in.content_length_n) {
-            b->pos += r->headers_in.content_length_n;
+            b->pos += (size_t) r->headers_in.content_length_n;
             r->headers_in.content_length_n = 0;
 
         } else {
@@ -866,7 +866,7 @@ ngx_http_request_body_length_filter(ngx_http_request_t *r, ngx_chain_t *in)
             rb->rest -= size;
 
         } else {
-            cl->buf->pos += rb->rest;
+            cl->buf->pos += (size_t) rb->rest;
             rb->rest = 0;
             b->last = cl->buf->pos;
             b->last_buf = 1;
@@ -972,7 +972,7 @@ ngx_http_request_body_chunked_filter(ngx_http_request_t *r, ngx_chain_t *in)
                 size = cl->buf->last - cl->buf->pos;
 
                 if ((off_t) size > rb->chunked->size) {
-                    cl->buf->pos += rb->chunked->size;
+                    cl->buf->pos += (size_t) rb->chunked->size;
                     r->headers_in.content_length_n += rb->chunked->size;
                     rb->chunked->size = 0;
 
index 7face954fa2a40d7eda7fe43f9fcee8c277de2d1..193079230a4d8ae0bc2e2f8948f7c6e1a7d86393 100644 (file)
@@ -146,6 +146,14 @@ typedef __int64             off_t;
 typedef int                 dev_t;
 typedef unsigned int        ino_t;
 
+#elif __BORLANDC__
+
+/* off_t is redefined by sys/types.h used by zlib.h */
+#define __TYPES_H
+
+typedef int                 dev_t;
+typedef unsigned int        ino_t;
+
 #endif