Fix nghttp2_hd.c:1991:11: warning: ISO C90 forbids mixed declarations

and code
This commit is contained in:
Anders Broman 2020-05-13 21:32:35 +02:00
parent 2b11c51ccd
commit 95596f83a0
1 changed files with 18 additions and 7 deletions

View File

@ -790,6 +790,22 @@ static void emit_header(nghttp2_hd_nv *nv_out, nghttp2_hd_nv *nv) {
*nv_out = *nv; *nv_out = *nv;
} }
static void emit_dummy_header(nghttp2_hd_nv *nv_out, nghttp2_hd_nv *nv) {
const nghttp2_hd_static_entry *ent = &dissect_index_table[0];
nv->name = (nghttp2_rcbuf *)&ent->name;
nv->value = (nghttp2_rcbuf *)&ent->value;
nv->token = ent->token;
nv->flags = NGHTTP2_NV_FLAG_NONE;
DEBUGF("inflatehd: dummy header emission: %s: %s\n", nv->name->base,
nv->value->base);
/* ent->ref may be 0. This happens if the encoder emits literal
block larger than header table capacity with indexing. */
*nv_out = *nv;
}
static size_t count_encoded_length(size_t n, size_t prefix) { static size_t count_encoded_length(size_t n, size_t prefix) {
size_t k = (size_t)((1 << prefix) - 1); size_t k = (size_t)((1 << prefix) - 1);
size_t len = 0; size_t len = 0;
@ -1876,7 +1892,7 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
int busy = 0; int busy = 0;
nghttp2_mem *mem; nghttp2_mem *mem;
int dissection = 0; int dissection = 0;
const nghttp2_hd_static_entry *ent = &dissect_index_table[0]; nghttp2_hd_nv nv;
if (*inflate_flags == NGHTTP2_HD_INFLATE_DECODE) { if (*inflate_flags == NGHTTP2_HD_INFLATE_DECODE) {
dissection = 1; dissection = 1;
@ -1988,12 +2004,7 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
rv = NGHTTP2_ERR_HEADER_COMP; rv = NGHTTP2_ERR_HEADER_COMP;
goto fail; goto fail;
} }
nghttp2_hd_nv nv = {(nghttp2_rcbuf *)&ent->name, emit_dummy_header(nv_out, &nv);
(nghttp2_rcbuf *)&ent->value, ent->token,
NGHTTP2_NV_FLAG_NONE};
emit_header(nv_out, &nv);
DEBUGF("inflatehd dissect: index=%zu\n", inflater->left);
inflater->index = inflater->left; inflater->index = inflater->left;
--inflater->index; --inflater->index;
inflater->state = NGHTTP2_HD_STATE_OPCODE; inflater->state = NGHTTP2_HD_STATE_OPCODE;