Src/http/ngx_http_spdy_filter_module.c, latest changesets compiler warnings

src/http/ngx_http_spdy_filter_module.c, latest changesets compiler
warnings

In ngx_http_spdy_send_chain(ngx_connection_t *fc, ngx_chain_t *in, off_t
limit):

src/http/ngx_http_spdy_filter_module.c(682) : warning C4244: ‘function’
:
conversion from ‘off_t’ to ‘size_t’, possible loss of data

src/http/ngx_http_spdy_filter_module.c(701) : warning C4244: ‘-=’ :
conversion from ‘off_t’ to ‘size_t’, possible loss of data

src/http/ngx_http_spdy_filter_module.c(715) : warning C4244: ‘function’
:
conversion from ‘off_t’ to ‘size_t’, possible loss of data

src/http/ngx_http_spdy_filter_module.c(751) : warning C4244: ‘=’ :
conversion from ‘off_t’ to ‘size_t’, possible loss of data

src/http/ngx_http_spdy_filter_module.c(757) : warning C4244: ‘function’
:
conversion from ‘off_t’ to ‘size_t’, possible loss of data

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,246444,246444#msg-246444

On Tuesday 14 January 2014 16:26:41 itpp2012 wrote:

src/http/ngx_http_spdy_filter_module.c(715) : warning C4244: ‘function’ :
conversion from ‘off_t’ to ‘size_t’, possible loss of data

src/http/ngx_http_spdy_filter_module.c(751) : warning C4244: ‘=’ :
conversion from ‘off_t’ to ‘size_t’, possible loss of data

src/http/ngx_http_spdy_filter_module.c(757) : warning C4244: ‘function’ :
conversion from ‘off_t’ to ‘size_t’, possible loss of data

What compiler are you using?

wbr, Valentin V. Bartenev

VC 2010, 32bit mode.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,246444,246446#msg-246446

On Tuesday 14 January 2014 16:33:39 itpp2012 wrote:

VC 2010, 32bit mode.

Ok. Please, try a patch below:

diff -r 439d05a037a3 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 01:44:57 2014
+0400
@@ -35,7 +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,
  • ngx_http_spdy_stream_t *stream, ngx_buf_t *buf, off_t offset,
    size_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,
    @@ -702,7 +702,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 +752,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 +777,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, size_t size)
    {
    ngx_buf_t *chunk;
    ngx_chain_t *cl;

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.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,246444,246449#msg-246449

I see only the ‘#if (NGX_SUPPRESS_WARN)’ commit on hg, where are the
others?
can’t attach anything here, after changeset 5516:439d05a037a3 additional
changes are embedded here:
http://nginx-win.ecsds.eu/ngx_http_spdy_filter_module.c

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,246444,246470#msg-246470

On Tuesday 14 January 2014 17:36:23 itpp2012 wrote:

            }

            offset = 0;

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 B. [email protected]

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 B. [email protected]

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;

On Wednesday 15 January 2014 03:53:23 itpp2012 wrote:

I see only the ‘#if (NGX_SUPPRESS_WARN)’ commit on hg, where are the others?
can’t attach anything here, after changeset 5516:439d05a037a3 additional
changes are embedded here:
http://nginx-win.ecsds.eu/ngx_http_spdy_filter_module.c

It was delayed for internal review. The first patch was posted for
review
even before you have complained about the problem.

Now the second patch is committed too with expanded commit log:
http://hg.nginx.org/nginx/rev/9d1479234f3c

wbr, Valentin V. Bartenev

Aha, I need more patience :slight_smile:

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,246444,246478#msg-246478

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs