src/http/ngx_http_spdy_filter_module.c, latest changesets compiler warnings
Valentin V. Bartenev
vbart at nginx.com
Tue Jan 14 23:04:07 UTC 2014
On Tuesday 14 January 2014 17:36:23 itpp2012 wrote:
> You missed 2,
>
> Line +-683:
> if (offset) {
> cl = ngx_http_spdy_filter_get_shadow(stream, in->buf,
> // offset, size);
> (off_t) offset,
> (size_t) size);
> if (cl == NULL) {
> return NGX_CHAIN_ERROR;
> }
>
> and +-Line 760:
> if (offset) {
> // cl = ngx_http_spdy_filter_get_shadow(stream, in->buf, offset,
> size);
> cl = ngx_http_spdy_filter_get_shadow(stream, in->buf, (off_t)
> offset, (size_t) size);
> if (cl == NULL) {
> return NGX_CHAIN_ERROR;
> }
>
>
> Additional warning +-line 684:
> if (offset) {
> cl = ngx_http_spdy_filter_get_shadow(stream, in->buf,
> (off_t) offset, (size_t)
> size);
> if (cl == NULL) {
> return NGX_CHAIN_ERROR;
> }
>
> offset = 0;
>
> src\http\ngx_http_spdy_filter_module.c(685): warning C4701: potentially
> uninitialized local variable 'cl' used
>
> When I add +-line 629:
> ngx_http_spdy_stream_t *stream;
> ngx_http_spdy_loc_conf_t *slcf;
> ngx_http_spdy_out_frame_t *frame;
> + cl = NULL;
>
> The warning is gone.
>
[..]
Thanks! I've just checked these two patches on MSVC 2010,
and it seems all warnings are gone:
# HG changeset patch
# User Valentin Bartenev <vbart at nginx.com>
# Date 1389735892 -14400
# Node ID 439d05a037a344ae8d38b162a98391f92321d03b
# Parent e5fb14e850408b2250f81751b69d2f735bbe8edc
SPDY: fixed build, broken by b7ee1bae0ffa.
False positive warning about the "cl" variable may be uninitialized in
the ngx_http_spdy_filter_get_data_frame() call was suppressed.
It is always initialized either in the "while" cycle or in the following
"if" condition since frame_size cannot be zero.
diff -r e5fb14e85040 -r 439d05a037a3 src/http/ngx_http_spdy_filter_module.c
--- a/src/http/ngx_http_spdy_filter_module.c Tue Jan 14 16:24:45 2014 +0400
+++ b/src/http/ngx_http_spdy_filter_module.c Wed Jan 15 01:44:52 2014 +0400
@@ -665,6 +665,10 @@ ngx_http_spdy_send_chain(ngx_connection_
offset = 0;
}
+#if (NGX_SUPPRESS_WARN)
+ cl = NULL;
+#endif
+
slcf = ngx_http_get_module_loc_conf(r, ngx_http_spdy_module);
frame_size = (limit && limit <= (off_t) slcf->chunk_size)
# HG changeset patch
# User Valentin Bartenev <vbart at nginx.com>
# Date 1389740560 -14400
# Node ID 3d83b3f1354d7d56f1e31849bfa337f75d7b1d30
# Parent 439d05a037a344ae8d38b162a98391f92321d03b
SPDY: fixed off_t/size_t type conversions on 32 bits platforms.
diff -r 439d05a037a3 -r 3d83b3f1354d src/http/ngx_http_spdy_filter_module.c
--- a/src/http/ngx_http_spdy_filter_module.c Wed Jan 15 01:44:52 2014 +0400
+++ b/src/http/ngx_http_spdy_filter_module.c Wed Jan 15 03:02:40 2014 +0400
@@ -35,8 +35,7 @@ static ngx_inline ngx_int_t ngx_http_spd
ngx_connection_t *fc, ngx_http_spdy_stream_t *stream);
static ngx_chain_t *ngx_http_spdy_filter_get_shadow(
- ngx_http_spdy_stream_t *stream, ngx_buf_t *buf, size_t offset,
- size_t size);
+ ngx_http_spdy_stream_t *stream, ngx_buf_t *buf, off_t offset, off_t size);
static ngx_http_spdy_out_frame_t *ngx_http_spdy_filter_get_data_frame(
ngx_http_spdy_stream_t *stream, size_t len, ngx_chain_t *first,
ngx_chain_t *last);
@@ -702,7 +701,7 @@ ngx_http_spdy_send_chain(ngx_connection_
*ln = cl;
ln = &cl->next;
- rest -= size;
+ rest -= (size_t) size;
in = in->next;
if (in == NULL) {
@@ -752,7 +751,7 @@ ngx_http_spdy_send_chain(ngx_connection_
}
if (limit < (off_t) slcf->chunk_size) {
- frame_size = limit;
+ frame_size = (size_t) limit;
}
}
}
@@ -777,7 +776,7 @@ ngx_http_spdy_send_chain(ngx_connection_
static ngx_chain_t *
ngx_http_spdy_filter_get_shadow(ngx_http_spdy_stream_t *stream, ngx_buf_t *buf,
- size_t offset, size_t size)
+ off_t offset, off_t size)
{
ngx_buf_t *chunk;
ngx_chain_t *cl;
More information about the nginx
mailing list