More warning flags for --enable-werror

This commit is contained in:
Tatsuhiro Tsujikawa 2015-09-23 14:41:53 +09:00
parent 2be6a94d70
commit 28fe3e7e89
33 changed files with 355 additions and 310 deletions

View File

@ -166,8 +166,10 @@ fi
#
if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
AC_DEFINE([_U_], [__attribute__((unused))], [Hint to the compiler that a function parameters is not used])
AC_DEFINE([NGHTTP2_NORETURN], [__attribute__((noreturn))], [Hint to the compiler that a function never return])
else
AC_DEFINE([_U_], , [Hint to the compiler that a function parameters is not used])
AC_DEFINE([_U_], , [Hint to the compiler that a function parameters is not use AC_DEFINE([NGHTTP2_NORETURN], , [Hint to the compiler that a function never return])
d])
fi
AX_CXX_COMPILE_STDCXX_11([noext], [optional])
@ -638,6 +640,21 @@ if test "x$werror" != "xno"; then
AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"])
AX_CHECK_COMPILE_FLAG([-Wshorten-64-to-32], [CFLAGS="$CFLAGS -Wshorten-64-to-32"])
AX_CHECK_COMPILE_FLAG([-Wconversion], [CFLAGS="$CFLAGS -Wconversion"])
AX_CHECK_COMPILE_FLAG([-Wextended-offsetof], [CFLAGS="$CFLAGS -Wextended-offsetof"])
AX_CHECK_COMPILE_FLAG([-Wformat-nonliteral], [CFLAGS="$CFLAGS -Wformat-nonliteral"])
AX_CHECK_COMPILE_FLAG([-Wlanguage-extension-token], [CFLAGS="$CFLAGS -Wlanguage-extension-token"])
AX_CHECK_COMPILE_FLAG([-Wmissing-field-initializers], [CFLAGS="$CFLAGS -Wmissing-field-initializers"])
AX_CHECK_COMPILE_FLAG([-Wmissing-noreturn], [CFLAGS="$CFLAGS -Wmissing-noreturn"])
AX_CHECK_COMPILE_FLAG([-Wmissing-variable-declarations], [CFLAGS="$CFLAGS -Wmissing-variable-declarations"])
# Not used because we cannot change public structs
# AX_CHECK_COMPILE_FLAG([-Wpadded], [CFLAGS="$CFLAGS -Wpadded"])
AX_CHECK_COMPILE_FLAG([-Wsign-conversion], [CFLAGS="$CFLAGS -Wsign-conversion"])
# Not used because this basically disallows default case
# AX_CHECK_COMPILE_FLAG([-Wswitch-enum], [CFLAGS="$CFLAGS -Wswitch-enum"])
AX_CHECK_COMPILE_FLAG([-Wunreachable-code-break], [CFLAGS="$CFLAGS -Wunreachable-code-break"])
AX_CHECK_COMPILE_FLAG([-Wunused-macros], [CFLAGS="$CFLAGS -Wunused-macros"])
AX_CHECK_COMPILE_FLAG([-Wunused-parameter], [CFLAGS="$CFLAGS -Wunused-parameter"])
# Only work with Clang for the moment
AX_CHECK_COMPILE_FLAG([-Wheader-guard], [CFLAGS="$CFLAGS -Wheader-guard"])
fi

View File

@ -124,6 +124,7 @@ static char *strcopy(const char *s, size_t len) {
/*
* Prints error message |msg| and exit.
*/
NGHTTP2_NORETURN
static void die(const char *msg) {
fprintf(stderr, "FATAL: %s\n", msg);
exit(EXIT_FAILURE);
@ -133,6 +134,7 @@ static void die(const char *msg) {
* Prints error containing the function name |func| and message |msg|
* and exit.
*/
NGHTTP2_NORETURN
static void dief(const char *func, const char *msg) {
fprintf(stderr, "FATAL: %s: %s\n", func, msg);
exit(EXIT_FAILURE);
@ -142,6 +144,7 @@ static void dief(const char *func, const char *msg) {
* Prints error containing the function name |func| and error code
* |error_code| and exit.
*/
NGHTTP2_NORETURN
static void diec(const char *func, int error_code) {
fprintf(stderr, "FATAL: %s: error_code=%d, msg=%s\n", func, error_code,
nghttp2_strerror(error_code));
@ -657,10 +660,10 @@ static int parse_uri(struct URI *res, const char *uri) {
return -1;
}
offset = i;
res->port = port;
res->port = (uint16_t)port;
}
}
res->hostportlen = uri + offset + ipv6addr - res->host;
res->hostportlen = (size_t)(uri + offset + ipv6addr - res->host);
for (i = offset; i < len; ++i) {
if (uri[i] == '#') {
break;

View File

@ -129,7 +129,7 @@ static void deflate(nghttp2_hd_deflater *deflater,
exit(EXIT_FAILURE);
}
outlen = rv;
outlen = (size_t)rv;
printf("\nDeflate (%zu byte(s), ratio %.02f):\n\n", outlen,
sum == 0 ? 0 : (double)outlen / sum);
@ -180,7 +180,7 @@ int inflate_header_block(nghttp2_hd_inflater *inflater, uint8_t *in,
return -1;
}
proclen = rv;
proclen = (size_t)rv;
in += proclen;
inlen -= proclen;

View File

@ -109,8 +109,8 @@ static http2_stream_data *create_http2_stream_data(const char *uri,
u->field_data[UF_HOST].len);
if (u->field_set & (1 << UF_PORT)) {
stream_data->authoritylen +=
snprintf(stream_data->authority + u->field_data[UF_HOST].len, extra,
":%u", u->port);
(size_t)snprintf(stream_data->authority + u->field_data[UF_HOST].len,
extra, ":%u", u->port);
}
/* If we don't have path in URI, we use "/" as path. */
@ -203,7 +203,7 @@ static ssize_t send_callback(nghttp2_session *session _U_, const uint8_t *data,
http2_session_data *session_data = (http2_session_data *)user_data;
struct bufferevent *bev = session_data->bev;
bufferevent_write(bev, data, length);
return length;
return (ssize_t)length;
}
/* nghttp2_on_header_callback: Called when nghttp2 library emits
@ -440,7 +440,7 @@ static void readcb(struct bufferevent *bev, void *ptr) {
delete_http2_session_data(session_data);
return;
}
if (evbuffer_drain(input, readlen) != 0) {
if (evbuffer_drain(input, (size_t)readlen) != 0) {
warnx("Fatal error: evbuffer_drain failed");
delete_http2_session_data(session_data);
return;

View File

@ -220,7 +220,8 @@ static http2_session_data *create_http2_session_data(app_context *app_ctx,
session_data->bev = bufferevent_openssl_socket_new(
app_ctx->evbase, fd, ssl, BUFFEREVENT_SSL_ACCEPTING,
BEV_OPT_CLOSE_ON_FREE | BEV_OPT_DEFER_CALLBACKS);
rv = getnameinfo(addr, addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST);
rv = getnameinfo(addr, (socklen_t)addrlen, host, sizeof(host), NULL, 0,
NI_NUMERICHOST);
if (rv != 0) {
session_data->client_addr = strdup("(unknown)");
} else {
@ -275,7 +276,7 @@ static int session_recv(http2_session_data *session_data) {
warnx("Fatal error: %s", nghttp2_strerror((int)readlen));
return -1;
}
if (evbuffer_drain(input, readlen) != 0) {
if (evbuffer_drain(input, (size_t)readlen) != 0) {
warnx("Fatal error: evbuffer_drain failed");
return -1;
}
@ -295,7 +296,7 @@ static ssize_t send_callback(nghttp2_session *session _U_, const uint8_t *data,
return NGHTTP2_ERR_WOULDBLOCK;
}
bufferevent_write(bev, data, length);
return length;
return (ssize_t)length;
}
/* Returns nonzero if the string |s| ends with the substring |sub| */
@ -335,10 +336,11 @@ static char *percent_decode(const uint8_t *value, size_t valuelen) {
for (i = 0, j = 0; i < valuelen - 2;) {
if (value[i] != '%' || !isxdigit(value[i + 1]) ||
!isxdigit(value[i + 2])) {
res[j++] = value[i++];
res[j++] = (char)value[i++];
continue;
}
res[j++] = (hex_to_uint(value[i + 1]) << 4) + hex_to_uint(value[i + 2]);
res[j++] =
(char)(hex_to_uint(value[i + 1]) << 4) + hex_to_uint(value[i + 2]);
i += 3;
}
memcpy(&res[j], &value[i], 2);
@ -383,8 +385,8 @@ static int send_response(nghttp2_session *session, int32_t stream_id,
return 0;
}
const char ERROR_HTML[] = "<html><head><title>404</title></head>"
"<body><h1>404 Not Found</h1></body></html>";
static const char ERROR_HTML[] = "<html><head><title>404</title></head>"
"<body><h1>404 Not Found</h1></body></html>";
static int error_reply(nghttp2_session *session,
http2_stream_data *stream_data) {
@ -690,7 +692,7 @@ static void start_listen(struct event_base *evbase, const char *service,
struct evconnlistener *listener;
listener = evconnlistener_new_bind(
evbase, acceptcb, app_ctx, LEV_OPT_CLOSE_ON_FREE | LEV_OPT_REUSEABLE,
16, rp->ai_addr, rp->ai_addrlen);
16, rp->ai_addr, (int)rp->ai_addrlen);
if (listener) {
freeaddrinfo(res);

View File

@ -81,9 +81,9 @@
#define array_size(a) (sizeof((a)) / sizeof((a)[0]))
/* Returns the length of remaning data in buffer */
#define io_buf_len(iobuf) ((iobuf)->last - (iobuf)->pos)
#define io_buf_len(iobuf) ((size_t)((iobuf)->last - (iobuf)->pos))
/* Returns the space buffer can still accept */
#define io_buf_left(iobuf) ((iobuf)->end - (iobuf)->last)
#define io_buf_left(iobuf) ((size_t)((iobuf)->end - (iobuf)->last))
typedef struct {
/* beginning of buffer */
@ -160,11 +160,11 @@ typedef struct {
} timer;
/* document root */
const char *docroot;
static const char *docroot;
/* length of docroot */
size_t docrootlen;
static size_t docrootlen;
nghttp2_session_callbacks *shared_callbacks;
static nghttp2_session_callbacks *shared_callbacks;
static int handle_accept(io_loop *loop, uint32_t events, void *ptr);
static int handle_connection(io_loop *loop, uint32_t events, void *ptr);
@ -289,11 +289,11 @@ static size_t http_date(char *buf, time_t t) {
memcpy(p, " GMT", 4);
p += 4;
return p - buf;
return (size_t)(p - buf);
}
static char date[29];
static char datelen;
static size_t datelen;
static void update_date() { datelen = http_date(date, time(NULL)); }
@ -694,7 +694,7 @@ static int send_data_callback(nghttp2_session *session _U_,
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
length -= nread;
length -= (size_t)nread;
p += nread;
}
@ -730,7 +730,7 @@ static ssize_t resbuf_read_callback(nghttp2_session *session _U_,
nghttp2_data_source *source,
void *user_data _U_) {
stream *strm = source->ptr;
size_t left = strm->res_end - strm->res_begin;
size_t left = (size_t)(strm->res_end - strm->res_begin);
size_t nwrite = length < left ? length : left;
memcpy(buf, strm->res_begin, nwrite);
@ -740,7 +740,7 @@ static ssize_t resbuf_read_callback(nghttp2_session *session _U_,
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
}
return nwrite;
return (ssize_t)nwrite;
}
static int hex_digit(char c) {
@ -750,14 +750,14 @@ static int hex_digit(char c) {
static unsigned int hex_to_uint(char c) {
if (c <= '9') {
return c - '0';
return (unsigned int)(c - '0');
}
if (c <= 'F') {
return c - 'A' + 10;
return (unsigned int)(c - 'A' + 10);
}
return c - 'a' + 10;
return (unsigned int)(c - 'a' + 10);
}
static void percent_decode(io_buf *buf, const char *s) {
@ -767,12 +767,13 @@ static void percent_decode(io_buf *buf, const char *s) {
}
if (*s == '%' && hex_digit(*(s + 1)) && hex_digit(*(s + 2))) {
*buf->last++ = (hex_to_uint(*(s + 1)) << 4) + hex_to_uint(*(s + 2));
*buf->last++ =
(uint8_t)((hex_to_uint(*(s + 1)) << 4) + hex_to_uint(*(s + 2)));
s += 2;
continue;
}
*buf->last++ = *s;
*buf->last++ = (uint8_t)*s;
}
}
@ -807,7 +808,7 @@ static int make_path(io_buf *pathbuf, const char *req, size_t reqlen _U_) {
*pathbuf->last++ = '\0';
if (!check_path((const char *)p, pathbuf->last - 1 - p)) {
if (!check_path((const char *)p, (size_t)(pathbuf->last - 1 - p))) {
return -1;
}
@ -958,7 +959,8 @@ static int process_request(stream *strm, connection *conn) {
strm->fileleft = stbuf.st_size;
lastmodlen = http_date(lastmod, stbuf.st_mtim.tv_sec);
contentlengthlen = utos(contentlength, sizeof(contentlength), stbuf.st_size);
contentlengthlen =
utos(contentlength, sizeof(contentlength), (uint64_t)stbuf.st_size);
nva[nvlen].value = (uint8_t *)contentlength;
nva[nvlen].valuelen = contentlengthlen;
@ -1149,7 +1151,7 @@ static int do_read(connection *conn) {
return -1;
}
nproc = nghttp2_session_mem_recv(conn->session, buf, nread);
nproc = nghttp2_session_mem_recv(conn->session, buf, (size_t)nread);
if (nproc < 0) {
return -1;
@ -1204,13 +1206,13 @@ static int do_write(connection *conn) {
break;
}
if (io_buf_left(&conn->buf) < n) {
if (io_buf_left(&conn->buf) < (size_t)n) {
conn->cache = b;
conn->cachelen = n;
conn->cachelen = (size_t)n;
break;
}
io_buf_add(&conn->buf, b, n);
io_buf_add(&conn->buf, b, (size_t)n);
}
}
}

View File

@ -244,9 +244,9 @@ void nghttp2_bufs_seek_last_present(nghttp2_bufs *bufs) {
}
}
ssize_t nghttp2_bufs_len(nghttp2_bufs *bufs) {
size_t nghttp2_bufs_len(nghttp2_bufs *bufs) {
nghttp2_buf_chain *ci;
ssize_t len;
size_t len;
len = 0;
for (ci = bufs->head; ci; ci = ci->next) {
@ -256,10 +256,10 @@ ssize_t nghttp2_bufs_len(nghttp2_bufs *bufs) {
return len;
}
static ssize_t bufs_avail(nghttp2_bufs *bufs) {
return (ssize_t)(nghttp2_buf_avail(&bufs->cur->buf) +
(bufs->chunk_length - bufs->offset) *
(bufs->max_chunk - bufs->chunk_used));
static size_t bufs_avail(nghttp2_bufs *bufs) {
return nghttp2_buf_avail(&bufs->cur->buf) +
(bufs->chunk_length - bufs->offset) *
(bufs->max_chunk - bufs->chunk_used);
}
static int bufs_alloc_chain(nghttp2_bufs *bufs) {
@ -301,7 +301,7 @@ int nghttp2_bufs_add(nghttp2_bufs *bufs, const void *data, size_t len) {
nghttp2_buf *buf;
const uint8_t *p;
if (bufs_avail(bufs) < (ssize_t)len) {
if (bufs_avail(bufs) < len) {
return NGHTTP2_ERR_BUFFER_ERROR;
}
@ -310,7 +310,7 @@ int nghttp2_bufs_add(nghttp2_bufs *bufs, const void *data, size_t len) {
while (len) {
buf = &bufs->cur->buf;
nwrite = nghttp2_min((size_t)nghttp2_buf_avail(buf), len);
nwrite = nghttp2_min(nghttp2_buf_avail(buf), len);
if (nwrite == 0) {
rv = bufs_alloc_chain(bufs);
if (rv != 0) {

View File

@ -51,13 +51,13 @@ typedef struct {
uint8_t *mark;
} nghttp2_buf;
#define nghttp2_buf_len(BUF) ((ssize_t)((BUF)->last - (BUF)->pos))
#define nghttp2_buf_avail(BUF) ((ssize_t)((BUF)->end - (BUF)->last))
#define nghttp2_buf_mark_avail(BUF) ((ssize_t)((BUF)->mark - (BUF)->last))
#define nghttp2_buf_cap(BUF) ((ssize_t)((BUF)->end - (BUF)->begin))
#define nghttp2_buf_len(BUF) ((size_t)((BUF)->last - (BUF)->pos))
#define nghttp2_buf_avail(BUF) ((size_t)((BUF)->end - (BUF)->last))
#define nghttp2_buf_mark_avail(BUF) ((size_t)((BUF)->mark - (BUF)->last))
#define nghttp2_buf_cap(BUF) ((size_t)((BUF)->end - (BUF)->begin))
#define nghttp2_buf_pos_offset(BUF) ((ssize_t)((BUF)->pos - (BUF)->begin))
#define nghttp2_buf_last_offset(BUF) ((ssize_t)((BUF)->last - (BUF)->begin))
#define nghttp2_buf_pos_offset(BUF) ((size_t)((BUF)->pos - (BUF)->begin))
#define nghttp2_buf_last_offset(BUF) ((size_t)((BUF)->last - (BUF)->begin))
#define nghttp2_buf_shift_right(BUF, AMT) \
do { \
@ -380,6 +380,6 @@ int nghttp2_bufs_next_present(nghttp2_bufs *bufs);
/*
* Returns the buffer length of |bufs|.
*/
ssize_t nghttp2_bufs_len(nghttp2_bufs *bufs);
size_t nghttp2_bufs_len(nghttp2_bufs *bufs);
#endif /* NGHTTP2_BUF_H */

View File

@ -37,7 +37,7 @@ void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd) {
nghttp2_put_uint32be(&buf[0], (uint32_t)(hd->length << 8));
buf[3] = hd->type;
buf[4] = hd->flags;
nghttp2_put_uint32be(&buf[5], hd->stream_id);
nghttp2_put_uint32be(&buf[5], (uint32_t)hd->stream_id);
/* ignore hd->reserved for now */
}
@ -300,11 +300,11 @@ int nghttp2_frame_pack_headers(nghttp2_bufs *bufs, nghttp2_headers *frame,
void nghttp2_frame_pack_priority_spec(uint8_t *buf,
const nghttp2_priority_spec *pri_spec) {
nghttp2_put_uint32be(buf, pri_spec->stream_id);
nghttp2_put_uint32be(buf, (uint32_t)pri_spec->stream_id);
if (pri_spec->exclusive) {
buf[0] |= 0x80;
}
buf[4] = pri_spec->weight - 1;
buf[4] = (uint8_t)(pri_spec->weight - 1);
}
void nghttp2_frame_unpack_priority_spec(nghttp2_priority_spec *pri_spec,
@ -398,7 +398,7 @@ int nghttp2_frame_pack_settings(nghttp2_bufs *bufs, nghttp2_settings *frame) {
buf = &bufs->head->buf;
if (nghttp2_buf_avail(buf) < (ssize_t)frame->hd.length) {
if (nghttp2_buf_avail(buf) < frame->hd.length) {
return NGHTTP2_ERR_FRAME_SIZE_ERROR;
}
@ -417,7 +417,7 @@ size_t nghttp2_frame_pack_settings_payload(uint8_t *buf,
size_t niv) {
size_t i;
for (i = 0; i < niv; ++i, buf += NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH) {
nghttp2_put_uint16be(buf, iv[i].settings_id);
nghttp2_put_uint16be(buf, (uint16_t)iv[i].settings_id);
nghttp2_put_uint32be(buf + 2, iv[i].value);
}
return NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH * niv;
@ -507,7 +507,7 @@ int nghttp2_frame_pack_push_promise(nghttp2_bufs *bufs,
return rv;
}
nghttp2_put_uint32be(buf->pos, frame->promised_stream_id);
nghttp2_put_uint32be(buf->pos, (uint32_t)frame->promised_stream_id);
frame->padlen = 0;
frame->hd.length = nghttp2_bufs_len(bufs);
@ -562,7 +562,7 @@ int nghttp2_frame_pack_goaway(nghttp2_bufs *bufs, nghttp2_goaway *frame) {
nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
nghttp2_put_uint32be(buf->last, frame->last_stream_id);
nghttp2_put_uint32be(buf->last, (uint32_t)frame->last_stream_id);
buf->last += 4;
nghttp2_put_uint32be(buf->last, frame->error_code);
@ -639,7 +639,7 @@ int nghttp2_frame_pack_window_update(nghttp2_bufs *bufs,
nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
nghttp2_put_uint32be(buf->last, frame->window_size_increment);
nghttp2_put_uint32be(buf->last, (uint32_t)frame->window_size_increment);
buf->last += 4;
return 0;
@ -830,7 +830,7 @@ static void frame_set_pad(nghttp2_buf *buf, size_t padlen, int framehd_only) {
}
trail_padlen = padlen - 1;
buf->pos[NGHTTP2_FRAME_HDLEN] = trail_padlen;
buf->pos[NGHTTP2_FRAME_HDLEN] = (uint8_t)trail_padlen;
/* zero out padding */
memset(buf->last, 0, trail_padlen);
@ -871,7 +871,7 @@ int nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd,
buf = &bufs->head->buf;
assert(nghttp2_buf_avail(buf) >= (ssize_t)padlen - 1);
assert(nghttp2_buf_avail(buf) >= padlen - 1);
frame_set_pad(buf, padlen, framehd_only);

View File

@ -1457,7 +1457,7 @@ static int deflate_nv(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
DEBUGF(fprintf(stderr, "deflatehd: name/value match index=%zd\n", idx));
rv = emit_indexed_block(bufs, idx);
rv = emit_indexed_block(bufs, (size_t)idx);
if (rv != 0) {
return rv;
}
@ -1474,7 +1474,8 @@ static int deflate_nv(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
if (idx != -1 && idx < (ssize_t)NGHTTP2_STATIC_TABLE_LENGTH) {
nghttp2_nv nv_indname;
nv_indname = *nv;
nv_indname.name = nghttp2_hd_table_get(&deflater->ctx, idx)->nv.name;
nv_indname.name =
nghttp2_hd_table_get(&deflater->ctx, (size_t)idx)->nv.name;
new_ent = add_hd_table_incremental(&deflater->ctx, &nv_indname, token,
NGHTTP2_HD_FLAG_VALUE_ALLOC,
&deflater->map, hash);
@ -1495,7 +1496,7 @@ static int deflate_nv(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
if (idx == -1) {
rv = emit_newname_block(bufs, nv, indexing_mode);
} else {
rv = emit_indname_block(bufs, idx, nv, indexing_mode);
rv = emit_indname_block(bufs, (size_t)idx, nv, indexing_mode);
}
if (rv != 0) {
return rv;
@ -1731,7 +1732,7 @@ static ssize_t hd_inflate_read_huff(nghttp2_hd_inflater *inflater,
final = 1;
}
readlen = nghttp2_hd_huff_decode(&inflater->huff_decode_ctx, bufs, in,
last - in, final);
(size_t)(last - in), final);
if (readlen < 0) {
DEBUGF(fprintf(stderr, "inflatehd: huffman decoding failed\n"));
@ -1805,7 +1806,7 @@ static int hd_inflate_remove_bufs(nghttp2_hd_inflater *inflater, nghttp2_nv *nv,
nghttp2_bufs_reset(&inflater->nvbufs);
buflen = rv;
buflen = (size_t)rv;
if (value_only) {
/* we don't use this value, so no need to NULL-terminate */

View File

@ -80,7 +80,7 @@ static ssize_t huff_encode_sym(nghttp2_bufs *bufs, size_t *avail_ptr,
/* fast path, since most code is less than 8 */
if (nbits < 8) {
nghttp2_bufs_fast_addb_hold(bufs, code);
nghttp2_bufs_fast_addb_hold(bufs, (uint8_t)code);
*avail_ptr = nghttp2_bufs_cur_avail(bufs);
return (ssize_t)(8 - nbits);
}
@ -92,22 +92,22 @@ static ssize_t huff_encode_sym(nghttp2_bufs *bufs, size_t *avail_ptr,
}
if (nbits > 16) {
nghttp2_bufs_fast_addb(bufs, code >> 16);
nghttp2_bufs_fast_addb(bufs, (uint8_t)(code >> 16));
nbits -= 8;
}
if (nbits > 8) {
nghttp2_bufs_fast_addb(bufs, code >> 8);
nghttp2_bufs_fast_addb(bufs, (uint8_t)(code >> 8));
nbits -= 8;
}
if (nbits == 8) {
nghttp2_bufs_fast_addb(bufs, code);
nghttp2_bufs_fast_addb(bufs, (uint8_t)code);
*avail_ptr = nghttp2_bufs_cur_avail(bufs);
return 8;
}
nghttp2_bufs_fast_addb_hold(bufs, code);
nghttp2_bufs_fast_addb_hold(bufs, (uint8_t)code);
*avail_ptr = nghttp2_bufs_cur_avail(bufs);
return (ssize_t)(8 - nbits);
}
@ -145,7 +145,7 @@ int nghttp2_hd_huff_encode(nghttp2_bufs *bufs, const uint8_t *src,
avail = nghttp2_bufs_cur_avail(bufs);
}
}
rembits = huff_encode_sym(bufs, &avail, rembits, sym);
rembits = huff_encode_sym(bufs, &avail, (size_t)rembits, sym);
if (rembits < 0) {
return (int)rembits;
}

View File

@ -71,4 +71,7 @@ typedef struct {
uint32_t code;
} nghttp2_huff_sym;
extern const nghttp2_huff_sym huff_sym_table[];
extern const nghttp2_huff_decode huff_decode_table[][16];
#endif /* NGHTTP2_HD_HUFFMAN_H */

View File

@ -67,7 +67,7 @@ void *nghttp2_memdup(const void *src, size_t n, nghttp2_mem *mem) {
}
/* Generated by gendowncasetbl.py */
static const int DOWNCASE_TBL[] = {
static const uint8_t DOWNCASE_TBL[] = {
0 /* NUL */, 1 /* SOH */, 2 /* STX */, 3 /* ETX */,
4 /* EOT */, 5 /* ENQ */, 6 /* ACK */, 7 /* BEL */,
8 /* BS */, 9 /* HT */, 10 /* LF */, 11 /* VT */,

View File

@ -31,7 +31,7 @@
#include "nghttp2_hd.h"
#include "nghttp2_helper.h"
static char downcase(char c) {
static uint8_t downcase(uint8_t c) {
return 'A' <= c && c <= 'Z' ? (c - 'A' + 'a') : c;
}
@ -243,7 +243,7 @@ static int http_response_on_header(nghttp2_stream *stream, nghttp2_nv *nv,
if (nv->valuelen != 3) {
return NGHTTP2_ERR_HTTP_HEADER;
}
stream->status_code = parse_uint(nv->value, nv->valuelen);
stream->status_code = (int16_t)parse_uint(nv->value, nv->valuelen);
if (stream->status_code == -1) {
return NGHTTP2_ERR_HTTP_HEADER;
}
@ -301,7 +301,7 @@ int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
}
/* header field name must be lower-cased without exception */
for (i = 0; i < nv->namelen; ++i) {
char c = nv->name[i];
uint8_t c = nv->name[i];
if ('A' <= c && c <= 'Z') {
return NGHTTP2_ERR_HTTP_HEADER;
}

View File

@ -49,7 +49,7 @@ void nghttp2_map_free(nghttp2_map *map) {
void nghttp2_map_each_free(nghttp2_map *map,
int (*func)(nghttp2_map_entry *entry, void *ptr),
void *ptr) {
size_t i;
uint32_t i;
for (i = 0; i < map->tablelen; ++i) {
nghttp2_map_entry *entry;
for (entry = map->table[i]; entry;) {
@ -65,7 +65,7 @@ int nghttp2_map_each(nghttp2_map *map,
int (*func)(nghttp2_map_entry *entry, void *ptr),
void *ptr) {
int rv;
size_t i;
uint32_t i;
for (i = 0; i < map->tablelen; ++i) {
nghttp2_map_entry *entry;
for (entry = map->table[i]; entry; entry = entry->next) {
@ -85,15 +85,16 @@ void nghttp2_map_entry_init(nghttp2_map_entry *entry, key_type key) {
/* Same hash function in android HashMap source code. */
/* The |mod| must be power of 2 */
static int32_t hash(int32_t h, size_t mod) {
static uint32_t hash(int32_t key, uint32_t mod) {
uint32_t h = (uint32_t)key;
h ^= (h >> 20) ^ (h >> 12);
h ^= (h >> 7) ^ (h >> 4);
return h & (mod - 1);
}
static int insert(nghttp2_map_entry **table, size_t tablelen,
static int insert(nghttp2_map_entry **table, uint32_t tablelen,
nghttp2_map_entry *entry) {
int32_t h = hash(entry->key, tablelen);
uint32_t h = hash(entry->key, tablelen);
if (table[h] == NULL) {
table[h] = entry;
} else {
@ -111,8 +112,8 @@ static int insert(nghttp2_map_entry **table, size_t tablelen,
}
/* new_tablelen must be power of 2 */
static int resize(nghttp2_map *map, size_t new_tablelen) {
size_t i;
static int resize(nghttp2_map *map, uint32_t new_tablelen) {
uint32_t i;
nghttp2_map_entry **new_table;
new_table =
@ -156,7 +157,7 @@ int nghttp2_map_insert(nghttp2_map *map, nghttp2_map_entry *new_entry) {
}
nghttp2_map_entry *nghttp2_map_find(nghttp2_map *map, key_type key) {
int32_t h;
uint32_t h;
nghttp2_map_entry *entry;
h = hash(key, map->tablelen);
for (entry = map->table[h]; entry; entry = entry->next) {
@ -168,7 +169,7 @@ nghttp2_map_entry *nghttp2_map_find(nghttp2_map *map, key_type key) {
}
int nghttp2_map_remove(nghttp2_map *map, key_type key) {
int32_t h;
uint32_t h;
nghttp2_map_entry *entry, *prev;
h = hash(key, map->tablelen);
prev = NULL;

View File

@ -35,7 +35,7 @@
/* Implementation of unordered map */
typedef uint32_t key_type;
typedef int32_t key_type;
typedef struct nghttp2_map_entry {
struct nghttp2_map_entry *next;
@ -49,8 +49,8 @@ typedef struct nghttp2_map_entry {
typedef struct {
nghttp2_map_entry **table;
nghttp2_mem *mem;
size_t tablelen;
size_t size;
uint32_t tablelen;
} nghttp2_map;
/*

View File

@ -82,15 +82,15 @@ struct nghttp2_option {
/**
* NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE
*/
uint8_t no_auto_window_update;
int no_auto_window_update;
/**
* NGHTTP2_OPT_NO_RECV_CLIENT_MAGIC
*/
uint8_t no_recv_client_magic;
int no_recv_client_magic;
/**
* NGHTTP2_OPT_NO_HTTP_MESSAGING
*/
uint8_t no_http_messaging;
int no_http_messaging;
};
#endif /* NGHTTP2_OPTION_H */

View File

@ -297,10 +297,7 @@ static void active_outbound_item_reset(nghttp2_active_outbound_item *aob,
aob->state = NGHTTP2_OB_POP_ITEM;
}
/* The global variable for tests where we want to disable strict
preface handling. */
/* Specify NGHTTP2_EXTERN, so that we can test using Win build dll. */
NGHTTP2_EXTERN int nghttp2_enable_strict_preface = 1;
int nghttp2_enable_strict_preface = 1;
static int session_new(nghttp2_session **session_ptr,
const nghttp2_session_callbacks *callbacks,
@ -904,8 +901,8 @@ nghttp2_stream *nghttp2_session_open_stream(nghttp2_session *session,
}
nghttp2_stream_init(stream, stream_id, flags, initial_state, pri_spec->weight,
session->remote_settings.initial_window_size,
session->local_settings.initial_window_size,
(int32_t)session->remote_settings.initial_window_size,
(int32_t)session->local_settings.initial_window_size,
stream_user_data, mem);
if (stream_alloc) {
@ -1160,7 +1157,7 @@ void nghttp2_session_detach_idle_stream(nghttp2_session *session,
}
int nghttp2_session_adjust_closed_stream(nghttp2_session *session,
ssize_t offset) {
size_t offset) {
size_t num_stream_max;
int rv;
@ -1642,7 +1639,7 @@ static ssize_t session_call_select_padding(nghttp2_session *session,
ssize_t rv;
if (frame->hd.length >= max_payloadlen) {
return frame->hd.length;
return (ssize_t)frame->hd.length;
}
if (session->callbacks.select_padding_callback) {
@ -1658,7 +1655,7 @@ static ssize_t session_call_select_padding(nghttp2_session *session,
}
return rv;
}
return frame->hd.length;
return (ssize_t)frame->hd.length;
}
/* Add padding to HEADERS or PUSH_PROMISE. We use
@ -1686,7 +1683,7 @@ static int session_headers_add_pad(nghttp2_session *session,
return (int)padded_payloadlen;
}
padlen = padded_payloadlen - frame->hd.length;
padlen = (size_t)padded_payloadlen - frame->hd.length;
DEBUGF(fprintf(stderr, "send: padding selected: payloadlen=%zd, padlen=%zu\n",
padded_payloadlen, padlen));
@ -2714,7 +2711,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
everything, we will adjust it. */
buf->pos += datalen;
return datalen;
return (ssize_t)datalen;
}
case NGHTTP2_OB_SEND_NO_COPY: {
nghttp2_stream *stream;
@ -2796,7 +2793,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
buf->pos += datalen;
return datalen;
return (ssize_t)datalen;
}
}
}
@ -2840,8 +2837,8 @@ int nghttp2_session_send(nghttp2_session *session) {
if (datalen <= 0) {
return (int)datalen;
}
sentlen = session->callbacks.send_callback(session, data, datalen, 0,
session->user_data);
sentlen = session->callbacks.send_callback(session, data, (size_t)datalen,
0, session->user_data);
if (sentlen < 0) {
if (sentlen == NGHTTP2_ERR_WOULDBLOCK) {
/* Transmission canceled. Rewind the offset */
@ -2954,7 +2951,7 @@ static int session_handle_frame_size_error(nghttp2_session *session,
return nghttp2_session_terminate_session(session, NGHTTP2_FRAME_SIZE_ERROR);
}
static int get_error_code_from_lib_error_code(int lib_error_code) {
static uint32_t get_error_code_from_lib_error_code(int lib_error_code) {
switch (lib_error_code) {
case NGHTTP2_ERR_STREAM_CLOSED:
return NGHTTP2_STREAM_CLOSED;
@ -3123,8 +3120,8 @@ static int inflate_header_block(nghttp2_session *session, nghttp2_frame *frame,
return NGHTTP2_ERR_HEADER_COMP;
}
in += proclen;
inlen -= proclen;
*readlen_ptr += proclen;
inlen -= (size_t)proclen;
*readlen_ptr += (size_t)proclen;
DEBUGF(fprintf(stderr, "recv: proclen=%zd\n", proclen));
@ -3729,7 +3726,7 @@ session_update_remote_initial_window_size(nghttp2_session *session,
arg.session = session;
arg.new_window_size = new_initial_window_size;
arg.old_window_size = session->remote_settings.initial_window_size;
arg.old_window_size = (int32_t)session->remote_settings.initial_window_size;
return nghttp2_map_each(&session->streams,
update_remote_initial_window_size_func, &arg);
@ -3806,7 +3803,7 @@ int nghttp2_session_update_local_settings(nghttp2_session *session,
int rv;
size_t i;
int32_t new_initial_window_size = -1;
int32_t header_table_size = -1;
uint32_t header_table_size = 0;
uint8_t header_table_size_seen = 0;
/* Use the value last seen. */
for (i = 0; i < niv; ++i) {
@ -3816,7 +3813,7 @@ int nghttp2_session_update_local_settings(nghttp2_session *session,
header_table_size = iv[i].value;
break;
case NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
new_initial_window_size = iv[i].value;
new_initial_window_size = (int32_t)iv[i].value;
break;
}
}
@ -3830,7 +3827,7 @@ int nghttp2_session_update_local_settings(nghttp2_session *session,
if (new_initial_window_size != -1) {
rv = session_update_local_initial_window_size(
session, new_initial_window_size,
session->local_settings.initial_window_size);
(int32_t)session->local_settings.initial_window_size);
if (rv != 0) {
return rv;
}
@ -3957,7 +3954,8 @@ int nghttp2_session_on_settings_received(nghttp2_session *session,
"SETTINGS: too large SETTINGS_INITIAL_WINDOW_SIZE");
}
rv = session_update_remote_initial_window_size(session, entry->value);
rv = session_update_remote_initial_window_size(session,
(int32_t)entry->value);
if (nghttp2_is_fatal(rv)) {
return rv;
@ -4608,7 +4606,8 @@ static size_t inbound_frame_buf_read(nghttp2_inbound_frame *iframe,
const uint8_t *in, const uint8_t *last) {
size_t readlen;
readlen = nghttp2_min(last - in, nghttp2_buf_mark_avail(&iframe->sbuf));
readlen =
nghttp2_min((size_t)(last - in), nghttp2_buf_mark_avail(&iframe->sbuf));
iframe->sbuf.last = nghttp2_cpymem(iframe->sbuf.last, in, readlen);
@ -4693,7 +4692,7 @@ static ssize_t inbound_frame_compute_pad(nghttp2_inbound_frame *iframe) {
iframe->padlen = padlen;
return padlen;
return (ssize_t)padlen;
}
/*
@ -4713,11 +4712,10 @@ static ssize_t inbound_frame_effective_readlen(nghttp2_inbound_frame *iframe,
padlen = trail_padlen - payloadleft;
if (readlen < padlen) {
return -1;
} else {
return readlen - padlen;
}
return (ssize_t)(readlen - padlen);
}
return readlen;
return (ssize_t)(readlen);
}
ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
@ -4781,7 +4779,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
return rv;
}
return inlen;
return (ssize_t)inlen;
}
iframe->state = NGHTTP2_IB_READ_HEAD;
@ -5159,7 +5157,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
iframe->state = NGHTTP2_IB_IGN_PAYLOAD;
break;
}
iframe->frame.headers.padlen = padlen;
iframe->frame.headers.padlen = (size_t)padlen;
pri_fieldlen = nghttp2_frame_priority_len(iframe->frame.hd.flags);
@ -5237,7 +5235,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
break;
}
iframe->frame.push_promise.padlen = padlen;
iframe->frame.push_promise.padlen = (size_t)padlen;
if (iframe->payloadleft < 4) {
busy = 1;
@ -5353,9 +5351,10 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
iframe->payloadleft - data_readlen == trail_padlen));
rv = inflate_header_block(
session, &iframe->frame, &hd_proclen, (uint8_t *)in, data_readlen,
session, &iframe->frame, &hd_proclen, (uint8_t *)in,
(size_t)data_readlen,
(iframe->frame.hd.flags & NGHTTP2_FLAG_END_HEADERS) &&
iframe->payloadleft - data_readlen == trail_padlen,
iframe->payloadleft - (size_t)data_readlen == trail_padlen,
iframe->state == NGHTTP2_IB_READ_HEADER_BLOCK);
if (nghttp2_is_fatal(rv)) {
@ -5652,7 +5651,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
break;
}
iframe->frame.data.padlen = padlen;
iframe->frame.data.padlen = (size_t)padlen;
iframe->state = NGHTTP2_IB_READ_DATA;
@ -5694,12 +5693,17 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
data_readlen = inbound_frame_effective_readlen(
iframe, iframe->payloadleft, readlen);
padlen = readlen - data_readlen;
if (data_readlen == -1) {
/* everything is padding */
data_readlen = 0;
}
padlen = (ssize_t)readlen - data_readlen;
if (padlen > 0) {
/* Padding is considered as "consumed" immediately */
rv = nghttp2_session_consume(session, iframe->frame.hd.stream_id,
padlen);
(size_t)padlen);
if (nghttp2_is_fatal(rv)) {
return rv;
@ -5710,11 +5714,11 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
if (data_readlen > 0) {
if (session_enforce_http_messaging(session)) {
if (nghttp2_http_on_data_chunk(stream, data_readlen) != 0) {
if (nghttp2_http_on_data_chunk(stream, (size_t)data_readlen) != 0) {
if (session->opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE) {
/* Consume all data for connection immediately here */
rv = session_update_connection_consumed_size(session,
data_readlen);
rv = session_update_connection_consumed_size(
session, (size_t)data_readlen);
if (nghttp2_is_fatal(rv)) {
return rv;
@ -5734,7 +5738,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
if (session->callbacks.on_data_chunk_recv_callback) {
rv = session->callbacks.on_data_chunk_recv_callback(
session, iframe->frame.hd.flags, iframe->frame.hd.stream_id,
in - readlen, data_readlen, session->user_data);
in - readlen, (size_t)data_readlen, session->user_data);
if (rv == NGHTTP2_ERR_PAUSE) {
return in - first;
}
@ -5795,7 +5799,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
break;
case NGHTTP2_IB_IGN_ALL:
return inlen;
return (ssize_t)inlen;
}
if (!busy && in == last) {
@ -5816,7 +5820,7 @@ int nghttp2_session_recv(nghttp2_session *session) {
ssize_t readlen;
readlen = session_recv(session, buf, sizeof(buf));
if (readlen > 0) {
ssize_t proclen = nghttp2_session_mem_recv(session, buf, readlen);
ssize_t proclen = nghttp2_session_mem_recv(session, buf, (size_t)readlen);
if (proclen < 0) {
return (int)proclen;
}
@ -6104,7 +6108,7 @@ int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags,
for (i = niv; i > 0; --i) {
if (iv[i - 1].settings_id == NGHTTP2_SETTINGS_ENABLE_PUSH) {
session->pending_enable_push = iv[i - 1].value;
session->pending_enable_push = (uint8_t)iv[i - 1].value;
break;
}
}
@ -6147,17 +6151,17 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
if (payloadlen > nghttp2_buf_avail(buf)) {
if ((size_t)payloadlen > nghttp2_buf_avail(buf)) {
/* Resize the current buffer(s). The reason why we do +1 for
buffer size is for possible padding field. */
rv = nghttp2_bufs_realloc(&session->aob.framebufs,
NGHTTP2_FRAME_HDLEN + 1 + payloadlen);
(size_t)(NGHTTP2_FRAME_HDLEN + 1 + payloadlen));
if (rv != 0) {
DEBUGF(fprintf(stderr, "send: realloc buffer failed rv=%d", rv));
/* If reallocation failed, old buffers are still in tact. So
use safe limit. */
payloadlen = datamax;
payloadlen = (ssize_t)datamax;
DEBUGF(
fprintf(stderr, "send: use safe limit payloadlen=%zd", payloadlen));
@ -6171,7 +6175,7 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
}
/* Current max DATA length is less then buffer chunk size */
assert(nghttp2_buf_avail(buf) >= (ssize_t)datamax);
assert(nghttp2_buf_avail(buf) >= datamax);
data_flags = NGHTTP2_DATA_FLAG_NONE;
payloadlen = aux_data->data_prd.read_callback(
@ -6219,7 +6223,7 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
aux_data->no_copy = 1;
}
frame->hd.length = payloadlen;
frame->hd.length = (size_t)payloadlen;
frame->data.padlen = 0;
max_payloadlen = nghttp2_min(datamax, frame->hd.length + NGHTTP2_MAX_PADLEN);
@ -6231,7 +6235,7 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
return (int)padded_payloadlen;
}
frame->data.padlen = padded_payloadlen - payloadlen;
frame->data.padlen = (size_t)(padded_payloadlen - payloadlen);
nghttp2_frame_pack_frame_hd(buf->pos, &frame->hd);
@ -6543,7 +6547,7 @@ int nghttp2_session_set_next_stream_id(nghttp2_session *session,
return NGHTTP2_ERR_INVALID_ARGUMENT;
}
session->next_stream_id = next_stream_id;
session->next_stream_id = (uint32_t)next_stream_id;
return 0;
}

View File

@ -40,6 +40,11 @@
#include "nghttp2_callbacks.h"
#include "nghttp2_mem.h"
/* The global variable for tests where we want to disable strict
preface handling. */
/* Specify NGHTTP2_EXTERN, so that we can test using Win build dll. */
NGHTTP2_EXTERN extern int nghttp2_enable_strict_preface;
/*
* Option flags.
*/
@ -507,7 +512,7 @@ void nghttp2_session_detach_idle_stream(nghttp2_session *session,
* Out of memory
*/
int nghttp2_session_adjust_closed_stream(nghttp2_session *session,
ssize_t offset);
size_t offset);
/*
* Deletes idle stream to ensure that number of idle streams is in

View File

@ -44,7 +44,7 @@ void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id,
int32_t weight, int32_t remote_initial_window_size,
int32_t local_initial_window_size,
void *stream_user_data, nghttp2_mem *mem) {
nghttp2_map_entry_init(&stream->map_entry, stream_id);
nghttp2_map_entry_init(&stream->map_entry, (key_type)stream_id);
nghttp2_pq_init(&stream->obq, stream_weight_less, mem);
stream->stream_id = stream_id;
@ -113,7 +113,8 @@ static int stream_subtree_active(nghttp2_stream *stream) {
*/
static uint64_t stream_next_cycle(nghttp2_stream *stream, uint64_t last_cycle) {
return last_cycle +
(stream->last_writelen + 1) * NGHTTP2_MAX_WEIGHT / stream->weight;
(stream->last_writelen + 1) * NGHTTP2_MAX_WEIGHT /
(uint32_t)stream->weight;
}
static int stream_obq_push(nghttp2_stream *dep_stream, nghttp2_stream *stream) {

View File

@ -80,7 +80,7 @@ static int32_t submit_headers_shared(nghttp2_session *session, uint8_t flags,
goto fail;
}
stream_id = session->next_stream_id;
stream_id = (int32_t)session->next_stream_id;
session->next_stream_id += 2;
hcat = NGHTTP2_HCAT_REQUEST;
@ -313,7 +313,7 @@ int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags _U_,
flags_copy = NGHTTP2_FLAG_END_HEADERS;
promised_stream_id = session->next_stream_id;
promised_stream_id = (int32_t)session->next_stream_id;
session->next_stream_id += 2;
nghttp2_frame_push_promise_init(&frame->push_promise, flags_copy, stream_id,
@ -475,5 +475,5 @@ ssize_t nghttp2_pack_settings_payload(uint8_t *buf, size_t buflen,
return NGHTTP2_ERR_INSUFF_BUFSIZE;
}
return nghttp2_frame_pack_settings_payload(buf, iv, niv);
return (ssize_t)nghttp2_frame_pack_settings_payload(buf, iv, niv);
}

View File

@ -38,18 +38,19 @@ json_t *dump_header_table(nghttp2_hd_context *context) {
for (i = 0; i < context->hd_table.len; ++i) {
nghttp2_hd_entry *ent = nghttp2_hd_table_get(context, i);
json_t *outent = json_object();
json_object_set_new(outent, "index", json_integer(i + 1));
json_object_set_new(outent, "index", json_integer((json_int_t)(i + 1)));
dump_val(outent, "name", ent->nv.name, ent->nv.namelen);
dump_val(outent, "value", ent->nv.value, ent->nv.valuelen);
json_object_set_new(outent, "size",
json_integer(ent->nv.namelen + ent->nv.valuelen +
NGHTTP2_HD_ENTRY_OVERHEAD));
json_object_set_new(outent, "size", json_integer((json_int_t)(
ent->nv.namelen + ent->nv.valuelen +
NGHTTP2_HD_ENTRY_OVERHEAD)));
json_array_append_new(entries, outent);
}
json_object_set_new(obj, "entries", entries);
json_object_set_new(obj, "size", json_integer(context->hd_table_bufsize));
json_object_set_new(obj, "max_size",
json_integer(context->hd_table_bufsize_max));
json_object_set_new(obj, "size",
json_integer((json_int_t)(context->hd_table_bufsize)));
json_object_set_new(obj, "max_size", json_integer((json_int_t)(
context->hd_table_bufsize_max)));
return obj;
}

View File

@ -33,8 +33,8 @@
#include "nghttp2_gzip.h"
static ssize_t deflate_data(uint8_t *out, size_t outlen, const uint8_t *in,
size_t inlen) {
static size_t deflate_data(uint8_t *out, size_t outlen, const uint8_t *in,
size_t inlen) {
int rv;
z_stream zst;
zst.next_in = Z_NULL;

View File

@ -69,7 +69,7 @@ int main(int argc _U_, char *argv[] _U_) {
num_tests_failed = CU_get_number_of_tests_failed();
CU_cleanup_registry();
if (CU_get_error() == CUE_SUCCESS) {
return num_tests_failed;
return (int)num_tests_failed;
} else {
printf("CUnit Error: %s\n", CU_get_error_msg());
return CU_get_error();

View File

@ -62,18 +62,18 @@ static void data_feed_init(data_feed *df, nghttp2_bufs *bufs) {
static ssize_t null_send_callback(nghttp2_session *session _U_,
const uint8_t *data _U_, size_t len,
int flags _U_, void *user_data _U_) {
return len;
return (ssize_t)len;
}
static ssize_t data_feed_recv_callback(nghttp2_session *session _U_,
uint8_t *data, size_t len, int flags _U_,
void *user_data) {
data_feed *df = ((my_user_data *)user_data)->df;
size_t avail = df->datalimit - df->datamark;
size_t avail = (size_t)(df->datalimit - df->datamark);
size_t wlen = nghttp2_min(avail, len);
memcpy(data, df->datamark, wlen);
df->datamark += wlen;
return wlen;
return (ssize_t)wlen;
}
static ssize_t fixed_length_data_source_read_callback(
@ -91,7 +91,7 @@ static ssize_t fixed_length_data_source_read_callback(
if (ud->data_source_length == 0) {
*data_flags = NGHTTP2_DATA_FLAG_EOF;
}
return wlen;
return (ssize_t)wlen;
}
#define TEST_FAILMALLOC_RUN(FUN) \
@ -230,7 +230,7 @@ static void run_nghttp2_session_recv(void) {
data_feed df;
int rv;
nghttp2_nv *nva;
ssize_t nvlen;
size_t nvlen;
rv = frame_pack_bufs_init(&bufs);
@ -334,7 +334,7 @@ static void run_nghttp2_frame_pack_headers(void) {
MAKE_NV(":scheme", "https")};
int rv;
nghttp2_nv *nva;
ssize_t nvlen;
size_t nvlen;
rv = frame_pack_bufs_init(&bufs);

View File

@ -377,7 +377,7 @@ int main(int argc _U_, char *argv[] _U_) {
num_tests_failed = CU_get_number_of_tests_failed();
CU_cleanup_registry();
if (CU_get_error() == CUE_SUCCESS) {
return num_tests_failed;
return (int)num_tests_failed;
} else {
printf("CUnit Error: %s\n", CU_get_error_msg());
return CU_get_error();

View File

@ -104,8 +104,8 @@ void test_nghttp2_bufs_addb(void) {
rv = nghttp2_bufs_addb(&bufs, 254);
CU_ASSERT(0 == rv);
CU_ASSERT(i + 2 == nghttp2_buf_len(&bufs.cur->buf));
CU_ASSERT(i + 2 == nghttp2_bufs_len(&bufs));
CU_ASSERT((size_t)(i + 2) == nghttp2_buf_len(&bufs.cur->buf));
CU_ASSERT((size_t)(i + 2) == nghttp2_bufs_len(&bufs));
CU_ASSERT(254 == *(bufs.cur->buf.last - 1));
CU_ASSERT(bufs.cur == bufs.head);
}
@ -217,7 +217,7 @@ void test_nghttp2_bufs_remove(void) {
outlen = nghttp2_bufs_remove(&bufs, &out);
CU_ASSERT(11 == outlen);
CU_ASSERT(0 == memcmp("hello world", out, outlen));
CU_ASSERT(0 == memcmp("hello world", out, (size_t)outlen));
CU_ASSERT(11 == nghttp2_bufs_len(&bufs));
mem->free(out, NULL);
@ -228,7 +228,7 @@ void test_nghttp2_bufs_reset(void) {
int rv;
nghttp2_bufs bufs;
nghttp2_buf_chain *ci;
ssize_t offset = 9;
size_t offset = 9;
nghttp2_mem *mem;
mem = nghttp2_mem_default();
@ -253,7 +253,7 @@ void test_nghttp2_bufs_reset(void) {
CU_ASSERT(bufs.cur == bufs.head);
for (ci = bufs.head; ci; ci = ci->next) {
CU_ASSERT(offset == ci->buf.pos - ci->buf.begin);
CU_ASSERT((ssize_t)offset == ci->buf.pos - ci->buf.begin);
CU_ASSERT(ci->buf.pos == ci->buf.last);
}

View File

@ -75,9 +75,9 @@ void test_nghttp2_frame_pack_headers() {
nghttp2_bufs bufs;
nghttp2_nv *nva;
nghttp2_priority_spec pri_spec;
ssize_t nvlen;
size_t nvlen;
nva_out out;
ssize_t hdblocklen;
size_t hdblocklen;
int rv;
nghttp2_mem *mem;
@ -112,7 +112,7 @@ void test_nghttp2_frame_pack_headers() {
CU_ASSERT(NGHTTP2_DEFAULT_WEIGHT == oframe.pri_spec.weight);
hdblocklen = nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN;
CU_ASSERT(hdblocklen ==
CU_ASSERT((ssize_t)hdblocklen ==
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem));
CU_ASSERT(7 == out.nvlen);
@ -146,7 +146,7 @@ void test_nghttp2_frame_pack_headers() {
hdblocklen = nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN -
nghttp2_frame_priority_len(oframe.hd.flags);
CU_ASSERT(hdblocklen ==
CU_ASSERT((ssize_t)hdblocklen ==
inflate_hd(&inflater, &out, &bufs,
NGHTTP2_FRAME_HDLEN +
nghttp2_frame_priority_len(oframe.hd.flags),
@ -317,9 +317,9 @@ void test_nghttp2_frame_pack_push_promise() {
nghttp2_push_promise frame, oframe;
nghttp2_bufs bufs;
nghttp2_nv *nva;
ssize_t nvlen;
size_t nvlen;
nva_out out;
ssize_t hdblocklen;
size_t hdblocklen;
int rv;
nghttp2_mem *mem;
@ -346,7 +346,7 @@ void test_nghttp2_frame_pack_push_promise() {
CU_ASSERT((1U << 31) - 1 == oframe.promised_stream_id);
hdblocklen = nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN - 4;
CU_ASSERT(hdblocklen ==
CU_ASSERT((ssize_t)hdblocklen ==
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN + 4, mem));
CU_ASSERT(7 == out.nvlen);
@ -402,7 +402,7 @@ void test_nghttp2_frame_pack_goaway() {
rv = nghttp2_frame_pack_goaway(&bufs, &frame);
CU_ASSERT(0 == rv);
CU_ASSERT((ssize_t)(NGHTTP2_FRAME_HDLEN + 8 + opaque_data_len) ==
CU_ASSERT(NGHTTP2_FRAME_HDLEN + 8 + opaque_data_len ==
nghttp2_bufs_len(&bufs));
CU_ASSERT(0 == unpack_framebuf((nghttp2_frame *)&oframe, &bufs));
check_frame_header(24, NGHTTP2_GOAWAY, NGHTTP2_FLAG_NONE, 0, &oframe.hd);

View File

@ -62,7 +62,7 @@ void test_nghttp2_hd_deflate(void) {
CU_ASSERT(0 == nghttp2_hd_inflate_init(&inflater, mem));
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva1, ARRLEN(nva1));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -76,7 +76,7 @@ void test_nghttp2_hd_deflate(void) {
/* Second headers */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva2, ARRLEN(nva2));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -91,7 +91,7 @@ void test_nghttp2_hd_deflate(void) {
/* Third headers, including same header field name, but value is not
the same. */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva3, ARRLEN(nva3));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -105,7 +105,7 @@ void test_nghttp2_hd_deflate(void) {
/* Fourth headers, including duplicate header fields. */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva4, ARRLEN(nva4));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -119,7 +119,7 @@ void test_nghttp2_hd_deflate(void) {
/* Fifth headers includes empty value */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva5, ARRLEN(nva5));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -158,7 +158,7 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
/* Encode 2 same headers. Emit 1 literal reprs and 1 index repr. */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva1, ARRLEN(nva1));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -172,7 +172,7 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
/* Encode 3 same headers. This time, emits 3 index reprs. */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva2, ARRLEN(nva2));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen == 3);
@ -206,7 +206,7 @@ void test_nghttp2_hd_inflate_indexed(void) {
nghttp2_bufs_addb(&bufs, (1 << 7) | 4);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(1 == blocklen);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
@ -221,7 +221,7 @@ void test_nghttp2_hd_inflate_indexed(void) {
/* index = 0 is error */
nghttp2_bufs_addb(&bufs, 1 << 7);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(1 == blocklen);
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
@ -253,7 +253,7 @@ void test_nghttp2_hd_inflate_indname_noinc(void) {
CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 57, &nv[i],
NGHTTP2_HD_WITHOUT_INDEXING));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(blocklen > 0);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
@ -287,7 +287,7 @@ void test_nghttp2_hd_inflate_indname_inc(void) {
CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 57, &nv,
NGHTTP2_HD_WITH_INDEXING));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(blocklen > 0);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
@ -336,7 +336,7 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void) {
CU_ASSERT(0 == nghttp2_hd_emit_indname_block(&bufs, 17, &nv,
NGHTTP2_HD_WITH_INDEXING));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(blocklen > 0);
@ -381,7 +381,7 @@ void test_nghttp2_hd_inflate_newname_noinc(void) {
CU_ASSERT(0 == nghttp2_hd_emit_newname_block(&bufs, &nv[i],
NGHTTP2_HD_WITHOUT_INDEXING));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(blocklen > 0);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
@ -415,7 +415,7 @@ void test_nghttp2_hd_inflate_newname_inc(void) {
CU_ASSERT(
0 == nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(blocklen > 0);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
@ -461,7 +461,7 @@ void test_nghttp2_hd_inflate_clearall_inc(void) {
CU_ASSERT(
0 == nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(blocklen > 0);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
@ -489,7 +489,7 @@ void test_nghttp2_hd_inflate_clearall_inc(void) {
CU_ASSERT(
0 == nghttp2_hd_emit_newname_block(&bufs, &nv, NGHTTP2_HD_WITH_INDEXING));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(blocklen > 0);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
@ -619,7 +619,7 @@ void test_nghttp2_hd_ringbuf_reserve(void) {
for (i = 0; i < 150; ++i) {
memcpy(nv.value, &i, sizeof(i));
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, &nv, 1);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -670,7 +670,7 @@ void test_nghttp2_hd_change_table_size(void) {
/* This will emit encoding context update with header table size 4096 */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -695,7 +695,7 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(1024 == inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -722,7 +722,7 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(0 == inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -757,7 +757,7 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -781,7 +781,7 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(16383 == inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -818,7 +818,7 @@ void test_nghttp2_hd_change_table_size(void) {
/* This emits context update with buffer size 1024 */
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -844,7 +844,7 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, UINT32_MAX));
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(UINT32_MAX == deflater.ctx.hd_table_bufsize_max);
@ -872,7 +872,7 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(3000 == deflater.ctx.hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva2, 1);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(3 < blocklen);
@ -905,7 +905,7 @@ static void check_deflate_inflate(nghttp2_hd_deflater *deflater,
nva_out_init(&out);
rv = nghttp2_hd_deflate_hd_bufs(deflater, &bufs, nva, nvlen);
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen >= 0);
@ -1107,7 +1107,7 @@ void test_nghttp2_hd_no_index(void) {
nghttp2_hd_inflate_init(&inflater, mem);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, ARRLEN(nva));
blocklen = nghttp2_bufs_len(&bufs);
blocklen = (ssize_t)nghttp2_bufs_len(&bufs);
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
@ -1179,7 +1179,7 @@ void test_nghttp2_hd_public_api(void) {
CU_ASSERT(blocklen > 0);
nghttp2_bufs_wrap_init(&bufs, buf, blocklen, mem);
nghttp2_bufs_wrap_init(&bufs, buf, (size_t)blocklen, mem);
bufs.head->buf.last += blocklen;
CU_ASSERT(blocklen == inflate_hd(inflater, NULL, &bufs, 0, mem));
@ -1192,8 +1192,8 @@ void test_nghttp2_hd_public_api(void) {
/* See NGHTTP2_ERR_INSUFF_BUFSIZE */
CU_ASSERT(0 == nghttp2_hd_deflate_new(&deflater, 4096));
blocklen =
nghttp2_hd_deflate_hd(deflater, buf, blocklen - 1, nva, ARRLEN(nva));
blocklen = nghttp2_hd_deflate_hd(deflater, buf, (size_t)(blocklen - 1), nva,
ARRLEN(nva));
CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == blocklen);
@ -1295,7 +1295,7 @@ void test_nghttp2_hd_huff_encode(void) {
len = nghttp2_hd_huff_decode(&ctx, &outbufs, bufs.cur->buf.pos,
nghttp2_bufs_len(&bufs), 1);
CU_ASSERT(nghttp2_bufs_len(&bufs) == len);
CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == len);
CU_ASSERT((ssize_t)sizeof(t1) == nghttp2_bufs_len(&outbufs));
CU_ASSERT(0 == memcmp(t1, outbufs.cur->buf.pos, sizeof(t1)));

View File

@ -93,7 +93,7 @@ void test_nghttp2_map(void) {
static void shuffle(int *a, int n) {
int i;
for (i = n - 1; i >= 1; --i) {
size_t j = (int)((double)(i + 1) * rand() / (RAND_MAX + 1.0));
size_t j = (size_t)((double)(i + 1) * rand() / (RAND_MAX + 1.0));
int t = a[j];
a[j] = a[i];
a[i] = t;
@ -103,8 +103,8 @@ static void shuffle(int *a, int n) {
static int eachfun(nghttp2_map_entry *entry _U_, void *ptr _U_) { return 0; }
#define NUM_ENT 6000
strentry arr[NUM_ENT];
int order[NUM_ENT];
static strentry arr[NUM_ENT];
static int order[NUM_ENT];
void test_nghttp2_map_functional(void) {
nghttp2_map map;

View File

@ -122,7 +122,7 @@ static void scripted_data_feed_init2(scripted_data_feed *df,
static ssize_t null_send_callback(nghttp2_session *session _U_,
const uint8_t *data _U_, size_t len,
int flags _U_, void *user_data _U_) {
return len;
return (ssize_t)len;
}
static ssize_t fail_send_callback(nghttp2_session *session _U_,
@ -135,7 +135,7 @@ static ssize_t fixed_bytes_send_callback(nghttp2_session *session _U_,
const uint8_t *data _U_, size_t len,
int flags _U_, void *user_data) {
size_t fixed_sendlen = ((my_user_data *)user_data)->fixed_sendlen;
return fixed_sendlen < len ? fixed_sendlen : len;
return (ssize_t)(fixed_sendlen < len ? fixed_sendlen : len);
}
static ssize_t scripted_recv_callback(nghttp2_session *session _U_,
@ -149,7 +149,7 @@ static ssize_t scripted_recv_callback(nghttp2_session *session _U_,
if (df->feedseq[df->seqidx] == 0) {
++df->seqidx;
}
return wlen;
return (ssize_t)wlen;
}
static ssize_t eof_recv_callback(nghttp2_session *session _U_,
@ -165,7 +165,7 @@ static ssize_t accumulator_send_callback(nghttp2_session *session _U_,
assert(acc->length + len < sizeof(acc->buf));
memcpy(acc->buf + acc->length, buf, len);
acc->length += len;
return len;
return (ssize_t)len;
}
static int on_begin_frame_callback(nghttp2_session *session _U_,
@ -235,7 +235,7 @@ static ssize_t select_padding_callback(nghttp2_session *session _U_,
const nghttp2_frame *frame,
size_t max_payloadlen, void *user_data) {
my_user_data *ud = (my_user_data *)user_data;
return nghttp2_min(max_payloadlen, frame->hd.length + ud->padlen);
return (ssize_t)nghttp2_min(max_payloadlen, frame->hd.length + ud->padlen);
}
static ssize_t too_large_data_source_length_callback(
@ -269,7 +269,7 @@ static ssize_t fixed_length_data_source_read_callback(
if (ud->data_source_length == 0) {
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
}
return wlen;
return (ssize_t)wlen;
}
static ssize_t temporal_failure_data_source_read_callback(
@ -315,7 +315,7 @@ static ssize_t no_copy_data_source_read_callback(
if (ud->data_source_length == 0) {
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
}
return wlen;
return (ssize_t)wlen;
}
static int send_data_callback(nghttp2_session *session _U_,
@ -328,7 +328,7 @@ static int send_data_callback(nghttp2_session *session _U_,
acc->length += NGHTTP2_FRAME_HDLEN;
if (frame->data.padlen) {
*(acc->buf + acc->length++) = frame->data.padlen - 1;
*(acc->buf + acc->length++) = (uint8_t)frame->data.padlen - 1;
}
acc->length += length;
@ -354,14 +354,13 @@ static ssize_t block_count_send_callback(nghttp2_session *session _U_,
const uint8_t *data _U_, size_t len,
int flags _U_, void *user_data) {
my_user_data *ud = (my_user_data *)user_data;
ssize_t r;
if (ud->block_count == 0) {
r = NGHTTP2_ERR_WOULDBLOCK;
} else {
--ud->block_count;
r = len;
return NGHTTP2_ERR_WOULDBLOCK;
}
return r;
--ud->block_count;
return (ssize_t)len;
}
static int on_header_callback(nghttp2_session *session _U_,
@ -446,12 +445,12 @@ void test_nghttp2_session_recv(void) {
scripted_data_feed df;
my_user_data user_data;
nghttp2_bufs bufs;
ssize_t framelen;
size_t framelen;
nghttp2_frame frame;
ssize_t i;
size_t i;
nghttp2_outbound_item *item;
nghttp2_nv *nva;
ssize_t nvlen;
size_t nvlen;
nghttp2_hd_deflater deflater;
int rv;
nghttp2_mem *mem;
@ -492,7 +491,7 @@ void test_nghttp2_session_recv(void) {
user_data.frame_recv_cb_called = 0;
user_data.begin_frame_cb_called = 0;
while ((ssize_t)df.seqidx < framelen) {
while (df.seqidx < framelen) {
CU_ASSERT(0 == nghttp2_session_recv(session));
}
CU_ASSERT(1 == user_data.frame_recv_cb_called);
@ -614,7 +613,7 @@ void test_nghttp2_session_recv_invalid_frame(void) {
nghttp2_bufs bufs;
nghttp2_frame frame;
nghttp2_nv *nva;
ssize_t nvlen;
size_t nvlen;
nghttp2_hd_deflater deflater;
int rv;
nghttp2_mem *mem;
@ -828,7 +827,7 @@ void test_nghttp2_session_recv_data_no_auto_flow_control(void) {
hd.flags = NGHTTP2_FLAG_PADDED;
hd.stream_id = 1;
nghttp2_frame_pack_frame_hd(data, &hd);
data[NGHTTP2_FRAME_HDLEN] = padlen;
data[NGHTTP2_FRAME_HDLEN] = (uint8_t)padlen;
/* First create stream 1, then close it. Check that data is
consumed for connection in this situation */
@ -1069,7 +1068,7 @@ void test_nghttp2_session_recv_headers_with_priority(void) {
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(nghttp2_buf_len(buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
CU_ASSERT(1 == ud.frame_recv_cb_called);
stream = nghttp2_session_get_stream(session, 3);
@ -1106,7 +1105,7 @@ void test_nghttp2_session_recv_headers_with_priority(void) {
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(nghttp2_buf_len(buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
CU_ASSERT(0 == ud.frame_recv_cb_called);
stream = nghttp2_session_get_stream(session, 5);
@ -1151,7 +1150,7 @@ void test_nghttp2_session_recv_headers_with_priority(void) {
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(nghttp2_buf_len(buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
CU_ASSERT(0 == ud.frame_recv_cb_called);
stream = nghttp2_session_get_stream(session, 1);
@ -1201,7 +1200,7 @@ void test_nghttp2_session_recv_premature_headers(void) {
nghttp2_put_uint32be(buf->pos, ((payloadlen - 1) << 8) + buf->pos[3]);
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf) - 1);
CU_ASSERT(rv == nghttp2_buf_len(buf) - 1);
CU_ASSERT((ssize_t)(nghttp2_buf_len(buf) - 1) == rv);
item = nghttp2_session_get_next_ob_item(session);
@ -1233,7 +1232,7 @@ void test_nghttp2_session_recv_premature_headers(void) {
nghttp2_put_uint32be(buf->pos, ((payloadlen - 1) << 8) + buf->pos[3]);
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf) - 1);
CU_ASSERT(rv == nghttp2_buf_len(buf) - 1);
CU_ASSERT((ssize_t)(nghttp2_buf_len(buf) - 1) == rv);
item = nghttp2_session_get_next_ob_item(session);
@ -1361,7 +1360,7 @@ void test_nghttp2_session_recv_settings_header_table_size(void) {
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(rv == nghttp2_buf_len(buf));
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
CU_ASSERT(1 == ud.frame_recv_cb_called);
CU_ASSERT(3000 == session->remote_settings.header_table_size);
@ -1396,7 +1395,7 @@ void test_nghttp2_session_recv_settings_header_table_size(void) {
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(rv == nghttp2_buf_len(buf));
CU_ASSERT((ssize_t)(nghttp2_buf_len(buf)) == rv);
CU_ASSERT(1 == ud.frame_recv_cb_called);
CU_ASSERT(3001 == session->remote_settings.header_table_size);
@ -1438,7 +1437,7 @@ void test_nghttp2_session_recv_settings_header_table_size(void) {
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(rv == nghttp2_buf_len(buf));
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
CU_ASSERT(1 == ud.frame_recv_cb_called);
CU_ASSERT(4096 == session->remote_settings.header_table_size);
@ -1481,7 +1480,7 @@ void test_nghttp2_session_recv_settings_header_table_size(void) {
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(rv == nghttp2_buf_len(buf));
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
CU_ASSERT(1 == ud.frame_recv_cb_called);
CU_ASSERT(0 == session->remote_settings.header_table_size);
@ -1536,7 +1535,7 @@ void test_nghttp2_session_continue(void) {
nghttp2_buf databuf;
nghttp2_frame frame;
nghttp2_nv *nva;
ssize_t nvlen;
size_t nvlen;
const nghttp2_frame *recv_frame;
nghttp2_frame_hd data_hd;
nghttp2_hd_deflater deflater;
@ -1717,7 +1716,7 @@ void test_nghttp2_session_add_frame(void) {
nghttp2_outbound_item *item;
nghttp2_frame *frame;
nghttp2_nv *nva;
ssize_t nvlen;
size_t nvlen;
nghttp2_mem *mem;
mem = nghttp2_mem_default();
@ -1740,7 +1739,7 @@ void test_nghttp2_session_add_frame(void) {
nghttp2_frame_headers_init(
&frame->headers, NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY,
session->next_stream_id, NGHTTP2_HCAT_REQUEST, NULL, nva, nvlen);
(int32_t)session->next_stream_id, NGHTTP2_HCAT_REQUEST, NULL, nva, nvlen);
session->next_stream_id += 2;
@ -2865,8 +2864,8 @@ void test_nghttp2_session_send_headers_start_stream(void) {
frame = &item->frame;
nghttp2_frame_headers_init(&frame->headers, NGHTTP2_FLAG_END_HEADERS,
session->next_stream_id, NGHTTP2_HCAT_REQUEST,
NULL, NULL, 0);
(int32_t)session->next_stream_id,
NGHTTP2_HCAT_REQUEST, NULL, NULL, 0);
session->next_stream_id += 2;
nghttp2_session_add_item(session, item);
@ -2916,7 +2915,7 @@ void test_nghttp2_session_send_headers_frame_size_error(void) {
nghttp2_outbound_item *item;
nghttp2_frame *frame;
nghttp2_nv *nva;
ssize_t nvlen;
size_t nvlen;
size_t vallen = NGHTTP2_HD_MAX_NV;
nghttp2_nv nv[28];
size_t nnv = ARRLEN(nv);
@ -2951,8 +2950,8 @@ void test_nghttp2_session_send_headers_frame_size_error(void) {
frame = &item->frame;
nghttp2_frame_headers_init(&frame->headers, NGHTTP2_FLAG_END_HEADERS,
session->next_stream_id, NGHTTP2_HCAT_REQUEST,
NULL, nva, nvlen);
(int32_t)session->next_stream_id,
NGHTTP2_HCAT_REQUEST, NULL, nva, nvlen);
session->next_stream_id += 2;
@ -3065,7 +3064,7 @@ void test_nghttp2_session_send_push_promise(void) {
nghttp2_frame_push_promise_init(&frame->push_promise,
NGHTTP2_FLAG_END_HEADERS, 1,
session->next_stream_id, NULL, 0);
(int32_t)session->next_stream_id, NULL, 0);
session->next_stream_id += 2;
@ -3160,7 +3159,7 @@ void test_nghttp2_session_upgrade(void) {
iv[0].value = 1;
iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
iv[1].value = 4095;
settings_payloadlen = nghttp2_pack_settings_payload(
settings_payloadlen = (size_t)nghttp2_pack_settings_payload(
settings_payload, sizeof(settings_payload), iv, 2);
/* Check client side */
@ -3205,7 +3204,7 @@ void test_nghttp2_session_upgrade(void) {
nghttp2_session_del(session);
/* Empty SETTINGS is OK */
settings_payloadlen = nghttp2_pack_settings_payload(
settings_payloadlen = (size_t)nghttp2_pack_settings_payload(
settings_payload, sizeof(settings_payload), NULL, 0);
nghttp2_session_client_new(&session, &callbacks, NULL);
@ -3483,7 +3482,7 @@ static ssize_t submit_data_twice_data_source_read_callback(
size_t len, uint32_t *data_flags, nghttp2_data_source *source _U_,
void *user_data _U_) {
*data_flags |= NGHTTP2_DATA_FLAG_EOF;
return nghttp2_min(len, 16);
return (ssize_t)nghttp2_min(len, 16);
}
static int submit_data_twice_on_frame_send_callback(nghttp2_session *session,
@ -5022,9 +5021,11 @@ void test_nghttp2_session_flow_control(void) {
negative. */
new_initial_window_size = 16 * 1024;
stream->remote_window_size =
new_initial_window_size - (session->remote_settings.initial_window_size -
stream->remote_window_size);
session->remote_settings.initial_window_size = new_initial_window_size;
new_initial_window_size -
((int32_t)session->remote_settings.initial_window_size -
stream->remote_window_size);
session->remote_settings.initial_window_size =
(uint32_t)new_initial_window_size;
CU_ASSERT(-48 * 1024 == stream->remote_window_size);
/* Back 48KiB to stream window */
@ -5523,7 +5524,7 @@ static void check_session_recv_data_with_padding(nghttp2_bufs *bufs,
nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
&pri_spec_default, NGHTTP2_STREAM_OPENING, NULL);
inlen = nghttp2_bufs_remove(bufs, &in);
inlen = (size_t)nghttp2_bufs_remove(bufs, &in);
ud.frame_recv_cb_called = 0;
ud.data_chunk_len = 0;
@ -5630,7 +5631,7 @@ void test_nghttp2_pack_settings_payload(void) {
len = nghttp2_pack_settings_payload(buf, sizeof(buf), iv, 2);
CU_ASSERT(2 * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH == len);
CU_ASSERT(0 == nghttp2_frame_unpack_settings_payload2(&resiv, &resniv, buf,
len, mem));
(size_t)len, mem));
CU_ASSERT(2 == resniv);
CU_ASSERT(NGHTTP2_SETTINGS_HEADER_TABLE_SIZE == resiv[0].settings_id);
CU_ASSERT(1023 == resiv[0].value);
@ -6932,7 +6933,7 @@ void test_nghttp2_session_stream_get_state(void) {
buf = &bufs.head->buf;
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(nghttp2_buf_len(buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
stream = nghttp2_session_find_stream(session, 1);
@ -6950,7 +6951,7 @@ void test_nghttp2_session_stream_get_state(void) {
buf = &bufs.head->buf;
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(nghttp2_buf_len(buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
stream = nghttp2_session_find_stream(session, 3);
@ -6992,7 +6993,7 @@ void test_nghttp2_session_stream_get_state(void) {
buf = &bufs.head->buf;
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(nghttp2_buf_len(buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
nghttp2_bufs_reset(&bufs);
@ -7063,7 +7064,7 @@ void test_nghttp2_session_stream_get_state(void) {
buf = &bufs.head->buf;
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(nghttp2_buf_len(buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
stream = nghttp2_session_find_stream(session, 7);
@ -7092,7 +7093,7 @@ void test_nghttp2_session_stream_get_state(void) {
buf = &bufs.head->buf;
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(nghttp2_buf_len(buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
stream = nghttp2_session_find_stream(session, 2);
@ -7108,7 +7109,7 @@ void test_nghttp2_session_stream_get_state(void) {
buf = &bufs.head->buf;
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_buf_len(buf));
CU_ASSERT(nghttp2_buf_len(buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(buf) == rv);
stream = nghttp2_session_find_stream(session, 2);
@ -7476,7 +7477,7 @@ void test_nghttp2_session_on_header_temporal_failure(void) {
ud.header_cb_called = 0;
rv = nghttp2_session_mem_recv(session, buf->pos, nghttp2_bufs_len(&bufs));
CU_ASSERT(rv == nghttp2_bufs_len(&bufs));
CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv);
CU_ASSERT(1 == ud.header_cb_called);
item = nghttp2_session_get_next_ob_item(session);
@ -7506,7 +7507,7 @@ void test_nghttp2_session_on_header_temporal_failure(void) {
ud.header_cb_called = 0;
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_bufs_len(&bufs));
CU_ASSERT(nghttp2_bufs_len(&bufs) == rv);
CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv);
CU_ASSERT(1 == ud.header_cb_called);
item = nghttp2_session_get_next_ob_item(session);
@ -7648,7 +7649,7 @@ void test_nghttp2_session_cancel_reserved_remote(void) {
nghttp2_stream *stream;
nghttp2_frame frame;
nghttp2_nv *nva;
ssize_t nvlen;
size_t nvlen;
nghttp2_hd_deflater deflater;
nghttp2_mem *mem;
nghttp2_bufs bufs;
@ -7688,7 +7689,7 @@ void test_nghttp2_session_cancel_reserved_remote(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
/* stream is not dangling, so assign NULL */
stream = NULL;
@ -7716,7 +7717,7 @@ void test_nghttp2_session_cancel_reserved_remote(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(1 == nghttp2_outbound_queue_size(&session->ob_reg));
@ -7856,7 +7857,7 @@ void test_nghttp2_session_on_begin_headers_temporal_failure(void) {
ud.frame_recv_cb_called = 0;
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_bufs_len(&bufs));
CU_ASSERT(nghttp2_bufs_len(&bufs) == rv);
CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv);
CU_ASSERT(0 == ud.header_cb_called);
CU_ASSERT(0 == ud.frame_recv_cb_called);
@ -7884,7 +7885,7 @@ void test_nghttp2_session_on_begin_headers_temporal_failure(void) {
ud.frame_recv_cb_called = 0;
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_bufs_len(&bufs));
CU_ASSERT(nghttp2_bufs_len(&bufs) == rv);
CU_ASSERT((ssize_t)nghttp2_bufs_len(&bufs) == rv);
CU_ASSERT(0 == ud.header_cb_called);
CU_ASSERT(0 == ud.frame_recv_cb_called);
@ -7997,7 +7998,8 @@ static void check_nghttp2_http_recv_headers_fail(
if (stream_state != -1) {
nghttp2_session_open_stream(session, stream_id, NGHTTP2_STREAM_FLAG_NONE,
&pri_spec_default, stream_state, NULL);
&pri_spec_default,
(nghttp2_stream_state)stream_state, NULL);
}
rv = pack_headers(&bufs, deflater, stream_id, NGHTTP2_FLAG_END_HEADERS, nva,
@ -8009,7 +8011,7 @@ static void check_nghttp2_http_recv_headers_fail(
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);
@ -8036,7 +8038,8 @@ static void check_nghttp2_http_recv_headers_ok(
if (stream_state != -1) {
nghttp2_session_open_stream(session, stream_id, NGHTTP2_STREAM_FLAG_NONE,
&pri_spec_default, stream_state, NULL);
&pri_spec_default,
(nghttp2_stream_state)stream_state, NULL);
}
rv = pack_headers(&bufs, deflater, stream_id, NGHTTP2_FLAG_END_HEADERS, nva,
@ -8048,7 +8051,7 @@ static void check_nghttp2_http_recv_headers_ok(
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
CU_ASSERT(1 == ud->frame_recv_cb_called);
@ -8290,7 +8293,7 @@ void test_nghttp2_http_content_length(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
CU_ASSERT(9000000000LL == stream->content_length);
CU_ASSERT(200 == stream->status_code);
@ -8313,7 +8316,7 @@ void test_nghttp2_http_content_length(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
stream = nghttp2_session_get_stream(session, 1);
@ -8360,7 +8363,7 @@ void test_nghttp2_http_content_length_mismatch(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type);
@ -8381,7 +8384,7 @@ void test_nghttp2_http_content_length_mismatch(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type);
@ -8402,7 +8405,7 @@ void test_nghttp2_http_content_length_mismatch(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type);
@ -8453,7 +8456,7 @@ void test_nghttp2_http_non_final_response(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type);
@ -8477,7 +8480,7 @@ void test_nghttp2_http_non_final_response(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_RST_STREAM == item->frame.hd.type);
@ -8502,7 +8505,7 @@ void test_nghttp2_http_non_final_response(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
@ -8524,7 +8527,7 @@ void test_nghttp2_http_non_final_response(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);
@ -8545,7 +8548,7 @@ void test_nghttp2_http_non_final_response(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
nghttp2_bufs_reset(&bufs);
@ -8556,7 +8559,7 @@ void test_nghttp2_http_non_final_response(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
@ -8599,7 +8602,7 @@ void test_nghttp2_http_trailer_headers(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
nghttp2_bufs_reset(&bufs);
@ -8611,7 +8614,7 @@ void test_nghttp2_http_trailer_headers(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
@ -8625,7 +8628,7 @@ void test_nghttp2_http_trailer_headers(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
nghttp2_bufs_reset(&bufs);
@ -8636,7 +8639,7 @@ void test_nghttp2_http_trailer_headers(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);
@ -8654,7 +8657,7 @@ void test_nghttp2_http_trailer_headers(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
nghttp2_bufs_reset(&bufs);
@ -8665,7 +8668,7 @@ void test_nghttp2_http_trailer_headers(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);
@ -8698,7 +8701,7 @@ void test_nghttp2_http_ignore_regular_header(void) {
const nghttp2_nv bad_ansnv[] = {
MAKE_NV(":authority", "localhost"), MAKE_NV(":scheme", "https"),
MAKE_NV(":path", "/"), MAKE_NV(":method", "GET"), MAKE_NV("bar", "buzz")};
ssize_t proclen;
size_t proclen;
size_t i;
mem = nghttp2_mem_default();
@ -8723,7 +8726,7 @@ void test_nghttp2_http_ignore_regular_header(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos + proclen,
nghttp2_buf_len(&bufs.head->buf) - proclen);
CU_ASSERT_FATAL(rv > 0);
proclen += rv;
proclen += (size_t)rv;
CU_ASSERT(nghttp2_nv_equal(&bad_ansnv[i], &ud.nv));
}
@ -8733,7 +8736,7 @@ void test_nghttp2_http_ignore_regular_header(void) {
/* header field "foo" must be ignored because it has illegal value.
So we have "bar" header field for 5th header. */
CU_ASSERT(nghttp2_nv_equal(&bad_ansnv[4], &ud.nv));
proclen += rv;
proclen += (size_t)rv;
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == proclen);
@ -8778,7 +8781,7 @@ void test_nghttp2_http_ignore_content_length(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
@ -8800,7 +8803,7 @@ void test_nghttp2_http_ignore_content_length(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
@ -8853,7 +8856,7 @@ void test_nghttp2_http_record_request_method(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((NGHTTP2_HTTP_FLAG_METH_CONNECT & stream->http_flags) > 0);
CU_ASSERT(-1 == stream->content_length);
@ -8895,7 +8898,7 @@ void test_nghttp2_http_push_promise(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
@ -8912,7 +8915,7 @@ void test_nghttp2_http_push_promise(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT(NULL == nghttp2_session_get_next_ob_item(session));
@ -8929,7 +8932,7 @@ void test_nghttp2_http_push_promise(void) {
rv = nghttp2_session_mem_recv(session, bufs.head->buf.pos,
nghttp2_buf_len(&bufs.head->buf));
CU_ASSERT(nghttp2_buf_len(&bufs.head->buf) == rv);
CU_ASSERT((ssize_t)nghttp2_buf_len(&bufs.head->buf) == rv);
item = nghttp2_session_get_next_ob_item(session);

View File

@ -165,9 +165,9 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
bp = *buf;
if (offset) {
ssize_t n;
size_t n;
n = nghttp2_min((ssize_t)offset, nghttp2_buf_len(&bp));
n = nghttp2_min(offset, nghttp2_buf_len(&bp));
bp.pos += n;
offset -= n;
}
@ -182,7 +182,7 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
}
bp.pos += rv;
processed += rv;
processed += (size_t)rv;
if (inflate_flags & NGHTTP2_HD_INFLATE_EMIT) {
if (out) {
@ -201,11 +201,11 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
nghttp2_hd_inflate_end_headers(inflater);
return processed;
return (ssize_t)processed;
}
int pack_headers(nghttp2_bufs *bufs, nghttp2_hd_deflater *deflater,
int32_t stream_id, int flags, const nghttp2_nv *nva,
int32_t stream_id, uint8_t flags, const nghttp2_nv *nva,
size_t nvlen, nghttp2_mem *mem) {
nghttp2_nv *dnva;
nghttp2_frame frame;
@ -223,8 +223,9 @@ int pack_headers(nghttp2_bufs *bufs, nghttp2_hd_deflater *deflater,
}
int pack_push_promise(nghttp2_bufs *bufs, nghttp2_hd_deflater *deflater,
int32_t stream_id, int flags, int32_t promised_stream_id,
const nghttp2_nv *nva, size_t nvlen, nghttp2_mem *mem) {
int32_t stream_id, uint8_t flags,
int32_t promised_stream_id, const nghttp2_nv *nva,
size_t nvlen, nghttp2_mem *mem) {
nghttp2_nv *dnva;
nghttp2_frame frame;
int rv;

View File

@ -82,12 +82,13 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
nghttp2_bufs *bufs, size_t offset, nghttp2_mem *mem);
int pack_headers(nghttp2_bufs *bufs, nghttp2_hd_deflater *deflater,
int32_t stream_id, int flags, const nghttp2_nv *nva,
int32_t stream_id, uint8_t flags, const nghttp2_nv *nva,
size_t nvlen, nghttp2_mem *mem);
int pack_push_promise(nghttp2_bufs *bufs, nghttp2_hd_deflater *deflater,
int32_t stream_id, int flags, int32_t promised_stream_id,
const nghttp2_nv *nva, size_t nvlen, nghttp2_mem *mem);
int32_t stream_id, uint8_t flags,
int32_t promised_stream_id, const nghttp2_nv *nva,
size_t nvlen, nghttp2_mem *mem);
int frame_pack_bufs_init(nghttp2_bufs *bufs);