[nginx] Win32: cleaned up most of C4244 warnings with 32-bit com...
Maxim Dounin
mdounin at mdounin.ru
Thu Jun 5 00:35:57 UTC 2025
details: http://freenginx.org/hg/nginx/rev/1c595b208741
branches:
changeset: 9375:1c595b208741
user: Maxim Dounin <mdounin at mdounin.ru>
date: Thu Jun 05 02:52:15 2025 +0300
description:
Win32: cleaned up most of C4244 warnings with 32-bit compilation.
C4244 warnings (conversion from 'type1' to 'type2', possible loss of data)
were disabled in 6861:e4590dfd97ff as part of introducing support for
64-bit compilation with MSVC. Still, these warnings remain useful
in some cases. Additionally, they explain multiple otherwise unneeded type
casts in the code.
This change resolves most of the warnings as observed during 32-bit
compilation with C4244 warnings enabled by introducing additional type
casts, in most cases already used in other parts of the code in similar
constructs.
diffstat:
src/core/ngx_inet.c | 2 +-
src/core/ngx_times.c | 2 +-
src/http/ngx_http_file_cache.c | 5 +++--
src/http/ngx_http_request_body.c | 3 ++-
4 files changed, 7 insertions(+), 5 deletions(-)
diffs (59 lines):
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -1286,7 +1286,7 @@ ngx_inet_add_addr(ngx_pool_t *pool, ngx_
ngx_memcpy(sa, sockaddr, socklen);
- ngx_inet_set_port(sa, u->port + i);
+ ngx_inet_set_port(sa, u->port + (in_port_t) i);
switch (sa->sa_family) {
diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -332,7 +332,7 @@ ngx_gmtime(time_t t, ngx_tm_t *tp)
t = 0;
}
- days = t / 86400;
+ days = (ngx_uint_t) t / 86400;
sec = t % 86400;
/*
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -387,7 +387,8 @@ ngx_http_file_cache_open(ngx_http_reques
if (of.is_directio) {
- c->body_start = ngx_align(c->body_start, clcf->directio_alignment);
+ c->body_start = ngx_align(c->body_start,
+ (size_t) clcf->directio_alignment);
c->buf = ngx_calloc_buf(r->pool);
if (c->buf == NULL) {
@@ -395,7 +396,7 @@ ngx_http_file_cache_open(ngx_http_reques
}
c->buf->start = ngx_pmemalign(r->pool, c->body_start,
- clcf->directio_alignment);
+ (size_t) clcf->directio_alignment);
if (c->buf->start == NULL) {
return NGX_ERROR;
}
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -1220,7 +1220,8 @@ ngx_http_request_body_chunked_filter(ngx
}
} else {
- ngx_memmove(b->last, cl->buf->pos, rb->chunked->size);
+ ngx_memmove(b->last, cl->buf->pos,
+ (size_t) rb->chunked->size);
b->last += rb->chunked->size;
cl->buf->pos += rb->chunked->size;
rb->chunked->size = 0;
More information about the nginx-devel
mailing list