Hi Ruslan, there is my fix to remove warning "using uninitialized variable".
I have moved the reading value of limit_rate variable from function ngx_http_update_location_config to function ngx_http_write_filter because value is initialized later. Best regards Miroslav Nový # HG changeset patch # User Miroslav Nový <miran...@gmail.com> # Date 1542811768 0 # Wed Nov 21 14:49:28 2018 +0000 # Node ID e2139cd62c7263dc182b11a847a6eaf2d9560a0d # Parent 82eed7650622fd780dcd4a86661de7b80b44199c Variables support in limit_rate and limit_rate_after fix Reading value of limit_rate variable moved to function ngx_http_write_filter because in function ngx_http_update_location_config is not inicialized yet. diff -r 82eed7650622 -r e2139cd62c72 src/http/ngx_http_core_module.c --- a/src/http/ngx_http_core_module.c Wed Nov 21 10:40:01 2018 +0000 +++ b/src/http/ngx_http_core_module.c Wed Nov 21 14:49:28 2018 +0000 @@ -1212,8 +1212,6 @@ void ngx_http_update_location_config(ngx_http_request_t *r) { - size_t limit_rate; - ngx_str_t val; ngx_http_core_loc_conf_t *clcf; clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); @@ -1283,20 +1281,6 @@ r->connection->tcp_nopush = NGX_TCP_NOPUSH_DISABLED; } - if (r->limit_rate == 0 - && clcf->limit_rate - && ngx_http_complex_value_size(r, clcf->limit_rate, &val, &limit_rate) - == NGX_OK) - { - if (limit_rate != (size_t) NGX_ERROR) { - r->limit_rate = limit_rate; - - } else if (val.len) { - ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "invalid \"limit_rate\" value \"%V\"", &val); - } - } - if (clcf->handler) { r->content_handler = clcf->handler; } diff -r 82eed7650622 -r e2139cd62c72 src/http/ngx_http_write_filter_module.c --- a/src/http/ngx_http_write_filter_module.c Wed Nov 21 10:40:01 2018 +0000 +++ b/src/http/ngx_http_write_filter_module.c Wed Nov 21 14:49:28 2018 +0000 @@ -48,7 +48,7 @@ ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) { off_t size, sent, nsent, limit; - size_t limit_rate_after; + ssize_t limit_rate, limit_rate_after; ngx_str_t val; ngx_uint_t last, flush, sync; ngx_msec_t delay; @@ -220,6 +220,25 @@ return NGX_ERROR; } + if (r->limit_rate == 0 + && clcf->limit_rate + && ngx_http_complex_value_size(r, clcf->limit_rate, &val, + &limit_rate) + == NGX_OK) + { + if (limit_rate_after != NGX_ERROR) { + r->limit_rate = limit_rate; + + } else if (val.len) { + ngx_log_error(NGX_LOG_ERR, c->log, 0, + "invalid \"limit_rate\" value \"%V\"", + &val); + } + } + + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http limit rate \"%z\"", + r->limit_rate); + if (r->limit_rate) { if (r->limit_rate_after == 0 && clcf->limit_rate_after @@ -227,7 +246,7 @@ &limit_rate_after) == NGX_OK) { - if (limit_rate_after != (size_t) NGX_ERROR) { + if (limit_rate_after != NGX_ERROR) { r->limit_rate_after = limit_rate_after; } else if (val.len) { _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel