diff --git a/examples/client.c b/examples/client.c index 58947fa1..c58e6ade 100644 --- a/examples/client.c +++ b/examples/client.c @@ -52,14 +52,12 @@ enum { }; #define MAKE_NV(NAME, VALUE) \ - {(uint8_t*)NAME, (uint8_t*)VALUE, \ - (uint16_t)(sizeof(NAME) - 1), (uint16_t)(sizeof(VALUE) - 1), \ - NGHTTP2_NV_FLAG_NONE } + {(uint8_t*)NAME, (uint8_t*)VALUE, sizeof(NAME) - 1, sizeof(VALUE) - 1, \ + NGHTTP2_NV_FLAG_NONE} #define MAKE_NV_CS(NAME, VALUE) \ - {(uint8_t*)NAME, (uint8_t*)VALUE, \ - (uint16_t)(sizeof(NAME) - 1), (uint16_t)(strlen(VALUE)), \ - NGHTTP2_NV_FLAG_NONE } + {(uint8_t*)NAME, (uint8_t*)VALUE, sizeof(NAME) - 1, strlen(VALUE), \ + NGHTTP2_NV_FLAG_NONE} struct Connection { SSL *ssl; diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h index e3af10ec..28fdae40 100644 --- a/lib/includes/nghttp2/nghttp2.h +++ b/lib/includes/nghttp2/nghttp2.h @@ -384,11 +384,11 @@ typedef struct { /** * The length of the |name|. */ - uint16_t namelen; + size_t namelen; /** * The length of the |value|. */ - uint16_t valuelen; + size_t valuelen; /** * Bitwise OR of one or more of :type:`nghttp2_nv_flag`. */ diff --git a/lib/nghttp2_hd.c b/lib/nghttp2_hd.c index b5b0ef01..8729cfb8 100644 --- a/lib/nghttp2_hd.c +++ b/lib/nghttp2_hd.c @@ -140,8 +140,8 @@ typedef struct { } nghttp2_nva_out; int nghttp2_hd_entry_init(nghttp2_hd_entry *ent, uint8_t flags, - uint8_t *name, uint16_t namelen, - uint8_t *value, uint16_t valuelen) + uint8_t *name, size_t namelen, + uint8_t *value, size_t valuelen) { int rv = 0; @@ -706,7 +706,7 @@ static int emit_indname_block(nghttp2_bufs *bufs, size_t index, } DEBUGF(fprintf(stderr, - "deflatehd: emit indname index=%zu, valuelen=%u, " + "deflatehd: emit indname index=%zu, valuelen=%zu, " "indexing=%d, no_index=%d\n", index, nv->valuelen, inc_indexing, no_index)); @@ -754,7 +754,7 @@ static int emit_newname_block(nghttp2_bufs *bufs, nghttp2_nv *nv, no_index = (nv->flags & NGHTTP2_NV_FLAG_NO_INDEX) != 0; DEBUGF(fprintf(stderr, - "deflatehd: emit newname namelen=%u, valuelen=%u, " + "deflatehd: emit newname namelen=%zu, valuelen=%zu, " "indexing=%d, no_index=%d\n", nv->namelen, nv->valuelen, inc_indexing, no_index)); diff --git a/lib/nghttp2_hd.h b/lib/nghttp2_hd.h index 31bbd57b..e87a5596 100644 --- a/lib/nghttp2_hd.h +++ b/lib/nghttp2_hd.h @@ -195,8 +195,8 @@ struct nghttp2_hd_inflater { * Out of memory. */ int nghttp2_hd_entry_init(nghttp2_hd_entry *ent, uint8_t flags, - uint8_t *name, uint16_t namelen, - uint8_t *value, uint16_t valuelen); + uint8_t *name, size_t namelen, + uint8_t *value, size_t valuelen); void nghttp2_hd_entry_free(nghttp2_hd_entry *ent); diff --git a/src/app_helper.cc b/src/app_helper.cc index 93edb5c9..5c6f81ec 100644 --- a/src/app_helper.cc +++ b/src/app_helper.cc @@ -483,7 +483,7 @@ int verbose_on_header_callback(nghttp2_session *session, { nghttp2_nv nva = { const_cast(name), const_cast(value), - static_cast(namelen), static_cast(valuelen) + namelen, valuelen }; for(auto& nv : http2::sort_nva(&nva, 1)) { diff --git a/src/http2.cc b/src/http2.cc index a7655aef..1d941f71 100644 --- a/src/http2.cc +++ b/src/http2.cc @@ -252,7 +252,7 @@ std::vector sort_nva(const nghttp2_nv *nva, size_t nvlen) break; } auto l = std::find(j, end, '\0'); - res.push_back({v[i].name, j, v[i].namelen, static_cast(l-j)}); + res.push_back({v[i].name, j, v[i].namelen, static_cast(l - j)}); j = l; } } @@ -346,12 +346,8 @@ nghttp2_nv make_nv(const std::string& name, const std::string& value, flags = no_index ? NGHTTP2_NV_FLAG_NO_INDEX : NGHTTP2_NV_FLAG_NONE; - return { - (uint8_t*)name.c_str(), - (uint8_t*)value.c_str(), - (uint16_t)name.size(), (uint16_t)value.size(), - flags - }; + return {(uint8_t*)name.c_str(), (uint8_t*)value.c_str(), + name.size(), value.size(), flags}; } Headers concat_norm_headers(Headers headers) diff --git a/src/http2.h b/src/http2.h index eefe5552..39cb3013 100644 --- a/src/http2.h +++ b/src/http2.h @@ -160,18 +160,15 @@ nghttp2_nv make_nv(const std::string& name, const std::string& value, template nghttp2_nv make_nv_ll(const char(&name)[N], const char(&value)[M]) { - return { (uint8_t*)name, (uint8_t*)value, - (uint16_t)(N - 1), (uint16_t)(M - 1), - NGHTTP2_NV_FLAG_NONE }; + return {(uint8_t*)name, (uint8_t*)value, N - 1, M - 1, NGHTTP2_NV_FLAG_NONE}; } // Create nghttp2_nv from string literal |name| and c-string |value|. template nghttp2_nv make_nv_lc(const char(&name)[N], const char *value) { - return { (uint8_t*)name, (uint8_t*)value, - (uint16_t)(N - 1), (uint16_t)strlen(value), - NGHTTP2_NV_FLAG_NONE }; + return {(uint8_t*)name, (uint8_t*)value, N - 1, strlen(value), + NGHTTP2_NV_FLAG_NONE}; } // Create nghttp2_nv from string literal |name| and std::string @@ -179,9 +176,8 @@ nghttp2_nv make_nv_lc(const char(&name)[N], const char *value) template nghttp2_nv make_nv_ls(const char(&name)[N], const std::string& value) { - return { (uint8_t*)name, (uint8_t*)value.c_str(), - (uint16_t)(N - 1), (uint16_t)value.size(), - NGHTTP2_NV_FLAG_NONE }; + return {(uint8_t*)name, (uint8_t*)value.c_str(), N - 1, value.size(), + NGHTTP2_NV_FLAG_NONE}; } // Appends headers in |headers| to |nv|. Certain headers, including diff --git a/src/http2_test.cc b/src/http2_test.cc index 1f957d6e..fa6dce8e 100644 --- a/src/http2_test.cc +++ b/src/http2_test.cc @@ -38,8 +38,8 @@ using namespace nghttp2; #define MAKE_NV(K, V) {(uint8_t*)K, (uint8_t*)V, \ - (uint16_t)(sizeof(K)-1), (uint16_t)(sizeof(V)-1), \ - NGHTTP2_NV_FLAG_NONE } + sizeof(K) - 1, sizeof(V) - 1, \ + NGHTTP2_NV_FLAG_NONE} namespace shrpx { diff --git a/tests/nghttp2_frame_test.c b/tests/nghttp2_frame_test.c index d3384c75..7f6d2141 100644 --- a/tests/nghttp2_frame_test.c +++ b/tests/nghttp2_frame_test.c @@ -569,7 +569,7 @@ void test_nghttp2_nv_array_copy(void) nghttp2_nv bignv; bignv.name = (uint8_t*)"echo"; - bignv.namelen = (uint16_t)strlen("echo"); + bignv.namelen = strlen("echo"); bignv.valuelen = (1 << 14) - 1; bignv.value = malloc(bignv.valuelen); memset(bignv.value, '0', bignv.valuelen);