Fix compile error with -Wshorten-64-to-32

The original patch was contributed by Alexis La Goutte
This commit is contained in:
Tatsuhiro Tsujikawa 2014-06-11 23:37:16 +09:00
parent 6e316e269f
commit 9b174bf5c9
20 changed files with 155 additions and 130 deletions

View File

@ -148,11 +148,11 @@ static ssize_t send_callback(nghttp2_session *session,
void *user_data)
{
struct Connection *connection;
ssize_t rv;
int rv;
connection = (struct Connection*)user_data;
connection->want_io = IO_NONE;
ERR_clear_error();
rv = SSL_write(connection->ssl, data, length);
rv = SSL_write(connection->ssl, data, (int)length);
if(rv < 0) {
int err = SSL_get_error(connection->ssl, rv);
if(err == SSL_ERROR_WANT_WRITE || err == SSL_ERROR_WANT_READ) {
@ -177,11 +177,11 @@ static ssize_t recv_callback(nghttp2_session *session,
void *user_data)
{
struct Connection *connection;
ssize_t rv;
int rv;
connection = (struct Connection*)user_data;
connection->want_io = IO_NONE;
ERR_clear_error();
rv = SSL_read(connection->ssl, buf, length);
rv = SSL_read(connection->ssl, buf, (int)length);
if(rv < 0) {
int err = SSL_get_error(connection->ssl, rv);
if(err == SSL_ERROR_WANT_WRITE || err == SSL_ERROR_WANT_READ) {

View File

@ -414,17 +414,18 @@ static int session_send(http2_session_data *session_data)
static void readcb(struct bufferevent *bev, void *ptr)
{
http2_session_data *session_data = (http2_session_data*)ptr;
int rv;
ssize_t readlen;
struct evbuffer *input = bufferevent_get_input(bev);
size_t datalen = evbuffer_get_length(input);
unsigned char *data = evbuffer_pullup(input, -1);
rv = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(rv < 0) {
warnx("Fatal error: %s", nghttp2_strerror(rv));
readlen = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(readlen < 0) {
warnx("Fatal error: %s", nghttp2_strerror((int)readlen));
delete_http2_session_data(session_data);
return;
}
evbuffer_drain(input, rv);
evbuffer_drain(input, readlen);
if(session_send(session_data) != 0) {
delete_http2_session_data(session_data);
return;

View File

@ -83,7 +83,7 @@ static int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
void *arg)
{
*data = next_proto_list;
*len = next_proto_list_len;
*len = (unsigned int)next_proto_list_len;
return SSL_TLSEXT_ERR_OK;
}
@ -240,16 +240,17 @@ static int session_send(http2_session_data *session_data)
function. */
static int session_recv(http2_session_data *session_data)
{
int rv;
ssize_t readlen;
struct evbuffer *input = bufferevent_get_input(session_data->bev);
size_t datalen = evbuffer_get_length(input);
unsigned char *data = evbuffer_pullup(input, -1);
rv = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(rv < 0) {
warnx("Fatal error: %s", nghttp2_strerror(rv));
readlen = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(readlen < 0) {
warnx("Fatal error: %s", nghttp2_strerror((int)readlen));
return -1;
}
evbuffer_drain(input, rv);
evbuffer_drain(input, readlen);
if(session_send(session_data) != 0) {
return -1;
}
@ -366,6 +367,7 @@ static int error_reply(nghttp2_session *session,
http2_stream_data *stream_data)
{
int rv;
ssize_t writelen;
int pipefd[2];
nghttp2_nv hdrs[] = {
MAKE_NV(":status", "404")
@ -384,10 +386,10 @@ static int error_reply(nghttp2_session *session,
return 0;
}
rv = write(pipefd[1], ERROR_HTML, sizeof(ERROR_HTML) - 1);
writelen = write(pipefd[1], ERROR_HTML, sizeof(ERROR_HTML) - 1);
close(pipefd[1]);
if(rv != sizeof(ERROR_HTML)) {
if(writelen != sizeof(ERROR_HTML)) {
close(pipefd[0]);
return -1;
}

View File

@ -234,7 +234,7 @@ ssize_t nghttp2_bufs_len(nghttp2_bufs *bufs)
return len;
}
static int bufs_avail(nghttp2_bufs *bufs)
static ssize_t bufs_avail(nghttp2_bufs *bufs)
{
return nghttp2_buf_avail(&bufs->cur->buf) +
(bufs->chunk_length - bufs->offset) * (bufs->max_chunk - bufs->chunk_used);

View File

@ -359,7 +359,7 @@ int nghttp2_frame_pack_headers(nghttp2_bufs *bufs,
nghttp2_hd_deflater *deflater)
{
size_t nv_offset;
ssize_t rv;
int rv;
nghttp2_buf *buf;
assert(bufs->head == bufs->cur);
@ -592,7 +592,7 @@ int nghttp2_frame_pack_push_promise(nghttp2_bufs *bufs,
nghttp2_hd_deflater *deflater)
{
size_t nv_offset = 4;
ssize_t rv;
int rv;
nghttp2_buf *buf;
assert(bufs->head == bufs->cur);
@ -970,8 +970,8 @@ void nghttp2_nv_array_sort(nghttp2_nv *nva, size_t nvlen)
qsort(nva, nvlen, sizeof(nghttp2_nv), nv_compar);
}
ssize_t nghttp2_nv_array_copy(nghttp2_nv **nva_ptr,
const nghttp2_nv *nva, size_t nvlen)
int nghttp2_nv_array_copy(nghttp2_nv **nva_ptr,
const nghttp2_nv *nva, size_t nvlen)
{
size_t i;
uint8_t *data;
@ -982,8 +982,7 @@ ssize_t nghttp2_nv_array_copy(nghttp2_nv **nva_ptr,
buflen += nva[i].namelen + nva[i].valuelen;
}
/* If all name/value pair is 0-length, remove them */
if(nvlen == 0 || buflen == 0) {
if(nvlen == 0) {
*nva_ptr = NULL;
return 0;
@ -1014,7 +1013,7 @@ ssize_t nghttp2_nv_array_copy(nghttp2_nv **nva_ptr,
data += nva[i].valuelen;
++p;
}
return nvlen;
return 0;
}
int nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv)

View File

@ -589,14 +589,14 @@ void nghttp2_nv_array_sort(nghttp2_nv *nva, size_t nvlen);
*
* The |*nva_ptr| must be freed using nghttp2_nv_array_del().
*
* This function returns the number of name/value pairs in |*nva_ptr|,
* or one of the following negative error codes:
* This function returns 0 if it succeeds or one of the following
* negative error codes:
*
* NGHTTP2_ERR_NOMEM
* Out of memory.
*/
ssize_t nghttp2_nv_array_copy(nghttp2_nv **nva_ptr,
const nghttp2_nv *nva, size_t nvlen);
int nghttp2_nv_array_copy(nghttp2_nv **nva_ptr,
const nghttp2_nv *nva, size_t nvlen);
/*
* Returns nonzero if the name/value pair |a| equals to |b|. The name

View File

@ -443,7 +443,7 @@ static int emit_literal_header(nghttp2_nv *nv_out, nghttp2_nv *nv)
return 0;
}
static size_t count_encoded_length(size_t n, int prefix)
static size_t count_encoded_length(size_t n, size_t prefix)
{
size_t k = (1 << prefix) - 1;
size_t len = 0;
@ -464,7 +464,7 @@ static size_t count_encoded_length(size_t n, int prefix)
return len;
}
static size_t encode_length(uint8_t *buf, size_t n, int prefix)
static size_t encode_length(uint8_t *buf, size_t n, size_t prefix)
{
size_t k = (1 << prefix) - 1;
size_t len = 0;
@ -507,8 +507,8 @@ static size_t encode_length(uint8_t *buf, size_t n, int prefix)
* partial decoding, or stores -1 in |*res|, indicating decoding
* error.
*/
static uint8_t* decode_length(ssize_t *res, int *final, ssize_t initial,
uint8_t *in, uint8_t *last, int prefix)
static uint8_t* decode_length(ssize_t *res, int *final, ssize_t initial,
uint8_t *in, uint8_t *last, size_t prefix)
{
int k = (1 << prefix) - 1, r;
ssize_t n = initial;
@ -624,7 +624,7 @@ static int emit_string(nghttp2_bufs *bufs,
size_t enclen, int huffman,
const uint8_t *str, size_t len)
{
size_t rv;
int rv;
uint8_t sb[16];
uint8_t *bufp;
size_t blocklen;
@ -998,7 +998,7 @@ static int check_index_range(nghttp2_hd_context *context, size_t idx)
return idx < context->hd_table.len + STATIC_TABLE_LENGTH;
}
static int get_max_index(nghttp2_hd_context *context)
static size_t get_max_index(nghttp2_hd_context *context)
{
return context->hd_table.len + STATIC_TABLE_LENGTH - 1;
}
@ -1352,7 +1352,7 @@ static void hd_inflate_set_huffman_encoded(nghttp2_hd_inflater *inflater,
static ssize_t hd_inflate_read_len(nghttp2_hd_inflater *inflater,
int *rfin,
uint8_t *in, uint8_t *last,
int prefix, size_t maxlen)
size_t prefix, size_t maxlen)
{
uint8_t *nin;
*rfin = 0;
@ -1389,21 +1389,21 @@ static ssize_t hd_inflate_read_huff(nghttp2_hd_inflater *inflater,
nghttp2_bufs *bufs,
uint8_t *in, uint8_t *last)
{
int rv;
ssize_t readlen;
int final = 0;
if(last - in >= inflater->left) {
last = in + inflater->left;
final = 1;
}
rv = nghttp2_hd_huff_decode(&inflater->huff_decode_ctx, bufs,
in, last - in, final);
readlen = nghttp2_hd_huff_decode(&inflater->huff_decode_ctx, bufs,
in, last - in, final);
if(rv < 0) {
if(readlen < 0) {
DEBUGF(fprintf(stderr, "inflatehd: huffman decoding failed\n"));
return rv;
return readlen;
}
inflater->left -= rv;
return rv;
inflater->left -= readlen;
return readlen;
}
/*
@ -1925,7 +1925,7 @@ ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_inflater *inflater,
rv = hd_inflate_read(inflater, &inflater->nvbufs, in, last);
if(rv < 0) {
DEBUGF(fprintf(stderr, "inflatehd: value read failure %zd: %s\n",
rv, nghttp2_strerror(rv)));
rv, nghttp2_strerror((int)rv)));
goto fail;
}

View File

@ -114,7 +114,7 @@ int nghttp2_hd_huff_encode(nghttp2_bufs *bufs,
const uint8_t *src, size_t srclen)
{
int rv;
int rembits = 8;
ssize_t rembits = 8;
size_t i;
size_t avail;
@ -135,7 +135,7 @@ int nghttp2_hd_huff_encode(nghttp2_bufs *bufs,
}
rembits = huff_encode_sym(bufs, &avail, rembits, sym);
if(rembits < 0) {
return rembits;
return (int)rembits;
}
}
/* 256 is special terminal symbol, pad with its prefix */

View File

@ -88,7 +88,7 @@ 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, int32_t mod)
static int32_t hash(int32_t h, size_t mod)
{
h ^= (h >> 20) ^ (h >> 12);
h ^= (h >> 7) ^ (h >> 4);

View File

@ -1451,8 +1451,8 @@ static int session_headers_add_pad(nghttp2_session *session,
padded_payloadlen = session_call_select_padding(session, frame,
NGHTTP2_MAX_PAYLOADLEN);
if(nghttp2_is_fatal(padded_payloadlen)) {
return padded_payloadlen;
if(nghttp2_is_fatal((int)padded_payloadlen)) {
return (int)padded_payloadlen;
}
padlen = padded_payloadlen - frame->hd.length;
@ -1546,7 +1546,7 @@ static int session_consider_blocked(nghttp2_session *session,
static int session_prep_frame(nghttp2_session *session,
nghttp2_outbound_item *item)
{
ssize_t framerv = 0;
int framerv = 0;
int rv;
if(item->frame_cat == NGHTTP2_CAT_CTRL) {
@ -2464,7 +2464,7 @@ int nghttp2_session_send(nghttp2_session *session)
for(;;) {
datalen = nghttp2_session_mem_send(session, &data);
if(datalen <= 0) {
return datalen;
return (int)datalen;
}
sentlen = session->callbacks.send_callback(session, data, datalen, 0,
session->user_data);
@ -2655,13 +2655,14 @@ static int session_inflate_handle_invalid_connection
* NGHTTP2_ERR_HEADER_COMP
* Header decompression failed
*/
static ssize_t inflate_header_block(nghttp2_session *session,
nghttp2_frame *frame,
size_t *readlen_ptr,
uint8_t *in, size_t inlen,
int final, int call_header_cb)
static int inflate_header_block(nghttp2_session *session,
nghttp2_frame *frame,
size_t *readlen_ptr,
uint8_t *in, size_t inlen,
int final, int call_header_cb)
{
ssize_t rv;
ssize_t proclen;
int rv;
int inflate_flags;
nghttp2_nv nv;
nghttp2_stream *stream;
@ -2671,12 +2672,12 @@ static ssize_t inflate_header_block(nghttp2_session *session,
DEBUGF(fprintf(stderr, "recv: decoding header block %zu bytes\n", inlen));
for(;;) {
inflate_flags = 0;
rv = nghttp2_hd_inflate_hd(&session->hd_inflater, &nv, &inflate_flags,
in, inlen, final);
if(nghttp2_is_fatal(rv)) {
return rv;
proclen = nghttp2_hd_inflate_hd(&session->hd_inflater, &nv, &inflate_flags,
in, inlen, final);
if(nghttp2_is_fatal((int)proclen)) {
return (int)proclen;
}
if(rv < 0) {
if(proclen < 0) {
if(session->iframe.state == NGHTTP2_IB_READ_HEADER_BLOCK) {
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
@ -2700,9 +2701,9 @@ static ssize_t inflate_header_block(nghttp2_session *session,
return NGHTTP2_ERR_HEADER_COMP;
}
in += rv;
inlen -= rv;
*readlen_ptr += rv;
in += proclen;
inlen -= proclen;
*readlen_ptr += proclen;
if(call_header_cb && (inflate_flags & NGHTTP2_HD_INFLATE_EMIT)) {
rv = session_call_on_header(session, frame, &nv);
/* This handles NGHTTP2_ERR_PAUSE and
@ -3923,11 +3924,11 @@ static int session_process_data_frame(nghttp2_session *session)
* return -1 too.
*/
static int adjust_recv_window_size(int32_t *recv_window_size_ptr,
int32_t delta,
size_t delta,
int32_t local_window_size)
{
if(*recv_window_size_ptr > local_window_size - delta ||
*recv_window_size_ptr > NGHTTP2_MAX_WINDOW_SIZE - delta) {
if(*recv_window_size_ptr > local_window_size - (int32_t)delta ||
*recv_window_size_ptr > NGHTTP2_MAX_WINDOW_SIZE - (int32_t)delta) {
return -1;
}
*recv_window_size_ptr += delta;
@ -3949,7 +3950,7 @@ static int adjust_recv_window_size(int32_t *recv_window_size_ptr,
static int session_update_recv_stream_window_size
(nghttp2_session *session,
nghttp2_stream *stream,
int32_t delta_size,
size_t delta_size,
int send_window_update)
{
int rv;
@ -3995,7 +3996,7 @@ static int session_update_recv_stream_window_size
*/
static int session_update_recv_connection_window_size
(nghttp2_session *session,
int32_t delta_size)
size_t delta_size)
{
int rv;
rv = adjust_recv_window_size(&session->recv_window_size, delta_size,
@ -4228,6 +4229,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
const uint8_t *first = in, *last = in + inlen;
nghttp2_inbound_frame *iframe = &session->iframe;
size_t readlen;
ssize_t padlen;
int rv;
int busy = 0;
nghttp2_frame_hd cont_hd;
@ -4596,8 +4598,8 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
case NGHTTP2_HEADERS:
if(iframe->padlen == 0 &&
iframe->frame.hd.flags & NGHTTP2_FLAG_PADDED) {
rv = inbound_frame_compute_pad(iframe);
if(rv < 0) {
padlen = inbound_frame_compute_pad(iframe);
if(padlen < 0) {
busy = 1;
rv = nghttp2_session_terminate_session(session,
NGHTTP2_PROTOCOL_ERROR);
@ -4607,7 +4609,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
iframe->state = NGHTTP2_IB_IGN_PAYLOAD;
break;
}
iframe->frame.headers.padlen = rv;
iframe->frame.headers.padlen = padlen;
pri_fieldlen = nghttp2_frame_priority_len(iframe->frame.hd.flags);
@ -4662,8 +4664,8 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
case NGHTTP2_PUSH_PROMISE:
if(iframe->padlen == 0 &&
iframe->frame.hd.flags & NGHTTP2_FLAG_PADDED) {
rv = inbound_frame_compute_pad(iframe);
if(rv < 0) {
padlen = inbound_frame_compute_pad(iframe);
if(padlen < 0) {
busy = 1;
rv = nghttp2_session_terminate_session(session,
NGHTTP2_PROTOCOL_ERROR);
@ -4674,7 +4676,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
break;
}
iframe->frame.push_promise.padlen = rv;
iframe->frame.push_promise.padlen = padlen;
if(iframe->payloadleft < 4) {
busy = 1;
@ -5081,8 +5083,8 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
busy = 1;
rv = inbound_frame_compute_pad(iframe);
if(rv < 0) {
padlen = inbound_frame_compute_pad(iframe);
if(padlen < 0) {
rv = nghttp2_session_terminate_session(session,
NGHTTP2_PROTOCOL_ERROR);
if(nghttp2_is_fatal(rv)) {
@ -5092,7 +5094,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
break;
}
iframe->frame.data.padlen = rv;
iframe->frame.data.padlen = padlen;
iframe->state = NGHTTP2_IB_READ_DATA;
@ -5212,13 +5214,13 @@ int nghttp2_session_recv(nghttp2_session *session)
if(readlen > 0) {
ssize_t proclen = nghttp2_session_mem_recv(session, buf, readlen);
if(proclen < 0) {
return proclen;
return (int)proclen;
}
assert(proclen == readlen);
} else if(readlen == 0 || readlen == NGHTTP2_ERR_WOULDBLOCK) {
return 0;
} else if(readlen == NGHTTP2_ERR_EOF) {
return readlen;
return NGHTTP2_ERR_EOF;
} else if(readlen < 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
@ -5439,7 +5441,7 @@ int nghttp2_session_pack_data(nghttp2_session *session,
size_t datamax,
nghttp2_private_data *frame)
{
ssize_t rv;
int rv;
uint32_t data_flags;
uint8_t flags;
ssize_t payloadlen;
@ -5464,9 +5466,9 @@ int nghttp2_session_pack_data(nghttp2_session *session,
if(payloadlen == NGHTTP2_ERR_DEFERRED ||
payloadlen == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE) {
DEBUGF(fprintf(stderr, "send: DATA postponed due to %s\n",
nghttp2_strerror(payloadlen)));
nghttp2_strerror((int)payloadlen)));
return payloadlen;
return (int)payloadlen;
}
if(payloadlen < 0 || datamax < (size_t)payloadlen) {
@ -5501,8 +5503,8 @@ int nghttp2_session_pack_data(nghttp2_session *session,
padded_payloadlen = session_call_select_padding(session, &data_frame,
datamax);
if(nghttp2_is_fatal(padded_payloadlen)) {
return padded_payloadlen;
if(nghttp2_is_fatal((int)padded_payloadlen)) {
return (int)padded_payloadlen;
}
padlen = padded_payloadlen - payloadlen;
@ -5620,7 +5622,7 @@ int32_t nghttp2_session_get_stream_remote_window_size(nghttp2_session* session,
return -1;
}
return nghttp2_session_next_data_read(session, stream);
return (int32_t)nghttp2_session_next_data_read(session, stream);
}
uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,

View File

@ -420,7 +420,7 @@ static int update_initial_window_size
new_window_size > NGHTTP2_MAX_WINDOW_SIZE) {
return -1;
}
*window_size_ptr = new_window_size;
*window_size_ptr = (int32_t)new_window_size;
return 0;
}

View File

@ -148,7 +148,7 @@ static int32_t submit_headers_shared_nva
const nghttp2_data_provider *data_prd,
void *stream_user_data)
{
ssize_t rv;
int rv;
nghttp2_nv *nva_copy;
nghttp2_priority_spec copy_pri_spec;
@ -165,7 +165,7 @@ static int32_t submit_headers_shared_nva
}
return submit_headers_shared(session, flags, stream_id,
&copy_pri_spec, nva_copy, rv, data_prd,
&copy_pri_spec, nva_copy, nvlen, data_prd,
stream_user_data);
}

View File

@ -63,9 +63,9 @@ int nghttp2_gzip_inflate(nghttp2_gzip *inflater,
if(inflater->finished) {
return -1;
}
inflater->zst.avail_in = *inlen_ptr;
inflater->zst.avail_in = (unsigned int)*inlen_ptr;
inflater->zst.next_in = (unsigned char*)in;
inflater->zst.avail_out = *outlen_ptr;
inflater->zst.avail_out = (unsigned int)*outlen_ptr;
inflater->zst.next_out = out;
rv = inflate(&inflater->zst, Z_NO_FLUSH);

View File

@ -46,9 +46,9 @@ static ssize_t deflate_data(uint8_t *out, size_t outlen,
rv = deflateInit(&zst, Z_DEFAULT_COMPRESSION);
assert(rv == Z_OK);
zst.avail_in = inlen;
zst.avail_in = (unsigned int)inlen;
zst.next_in = (uint8_t*)in;
zst.avail_out = outlen;
zst.avail_out = (unsigned int)outlen;
zst.next_out = out;
rv = deflate(&zst, Z_SYNC_FLUSH);
assert(rv == Z_OK);

View File

@ -254,7 +254,8 @@ static void run_nghttp2_session_recv(void)
ud.df = &df;
nghttp2_failmalloc_pause();
nvlen = nghttp2_nv_array_copy(&nva, nv, ARRLEN(nv));
nvlen = ARRLEN(nv);
nghttp2_nv_array_copy(&nva, nv, nvlen);
nghttp2_hd_deflate_init(&deflater);
nghttp2_session_server_new(&session, &callbacks, &ud);
nghttp2_failmalloc_unpause();
@ -362,8 +363,9 @@ static void run_nghttp2_frame_pack_headers(void)
if(rv != 0) {
goto inflate_init_fail;
}
nvlen = nghttp2_nv_array_copy(&nva, nv, ARRLEN(nv));
if(nvlen < 0) {
nvlen = ARRLEN(nv);
rv = nghttp2_nv_array_copy(&nva, nv, nvlen);
if(rv < 0) {
goto nv_copy_fail;
}
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_STREAM,

View File

@ -164,6 +164,7 @@ void test_nghttp2_bufs_remove(void)
nghttp2_buf_chain *chain;
int i;
uint8_t *out;
ssize_t outlen;
rv = nghttp2_bufs_init(&bufs, 1000, 3);
CU_ASSERT(0 == rv);
@ -185,10 +186,10 @@ void test_nghttp2_bufs_remove(void)
rv = nghttp2_bufs_add(&bufs, "world", 5);
CU_ASSERT(0 == rv);
rv = nghttp2_bufs_remove(&bufs, &out);
CU_ASSERT(11 == rv);
outlen = nghttp2_bufs_remove(&bufs, &out);
CU_ASSERT(11 == outlen);
CU_ASSERT(0 == memcmp("hello world", out, rv));
CU_ASSERT(0 == memcmp("hello world", out, outlen));
CU_ASSERT(0 == nghttp2_bufs_len(&bufs));
CU_ASSERT(bufs.cur->buf.pos == bufs.cur->buf.begin);

View File

@ -172,7 +172,6 @@ void test_nghttp2_frame_pack_headers_frame_too_large(void)
nghttp2_headers frame;
nghttp2_bufs bufs;
nghttp2_nv *nva;
ssize_t nvlen;
size_t big_vallen = NGHTTP2_HD_MAX_NV;
nghttp2_nv big_hds[16];
size_t big_hdslen = ARRLEN(big_hds);
@ -184,19 +183,19 @@ void test_nghttp2_frame_pack_headers_frame_too_large(void)
for(i = 0; i < big_hdslen; ++i) {
big_hds[i].name = (uint8_t*)"header";
big_hds[i].value = malloc(big_vallen+1);
memset(big_hds[i].value, '0'+i, big_vallen);
memset(big_hds[i].value, '0' + (int)i, big_vallen);
big_hds[i].value[big_vallen] = '\0';
big_hds[i].namelen = strlen((char*)big_hds[i].name);
big_hds[i].valuelen = big_vallen;
big_hds[i].flags = NGHTTP2_NV_FLAG_NONE;
}
nvlen = nghttp2_nv_array_copy(&nva, big_hds, big_hdslen);
nghttp2_nv_array_copy(&nva, big_hds, big_hdslen);
nghttp2_hd_deflate_init(&deflater);
nghttp2_frame_headers_init(&frame,
NGHTTP2_FLAG_END_STREAM|NGHTTP2_FLAG_END_HEADERS,
1000000007, NGHTTP2_HCAT_REQUEST,
NULL, nva, nvlen);
NULL, nva, big_hdslen);
rv = nghttp2_frame_pack_headers(&bufs, &frame, &deflater);
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == rv);
@ -611,10 +610,15 @@ void test_nghttp2_nv_array_copy(void)
rv = nghttp2_nv_array_copy(&nva, emptynv, ARRLEN(emptynv));
CU_ASSERT(0 == rv);
CU_ASSERT(NULL == nva);
CU_ASSERT(nva[0].namelen == 0);
CU_ASSERT(nva[0].valuelen == 0);
CU_ASSERT(nva[1].namelen == 0);
CU_ASSERT(nva[1].valuelen == 0);
nghttp2_nv_array_del(nva);
rv = nghttp2_nv_array_copy(&nva, nv, ARRLEN(nv));
CU_ASSERT(2 == rv);
CU_ASSERT(0 == rv);
CU_ASSERT(nva[0].namelen == 5);
CU_ASSERT(0 == memcmp("alpha", nva[0].name, 5));
CU_ASSERT(nva[0].valuelen = 5);
@ -628,7 +632,7 @@ void test_nghttp2_nv_array_copy(void)
/* Large header field is acceptable */
rv = nghttp2_nv_array_copy(&nva, &bignv, 1);
CU_ASSERT(1 == rv);
CU_ASSERT(0 == rv);
nghttp2_nv_array_del(nva);

View File

@ -104,13 +104,13 @@ void test_nghttp2_pq_update(void)
{
nghttp2_pq pq;
node nodes[10];
size_t i;
int i;
node *nd;
int ans[] = {-8, -6, -4, -2, 0, 1, 3, 5, 7, 9};
nghttp2_pq_init(&pq, node_compar);
for(i = 0; i < sizeof(nodes)/sizeof(nodes[0]); ++i) {
for(i = 0; i < (int)(sizeof(nodes)/sizeof(nodes[0])); ++i) {
nodes[i].key = i;
nodes[i].val = i;
nghttp2_pq_push(&pq, &nodes[i]);
@ -118,7 +118,7 @@ void test_nghttp2_pq_update(void)
nghttp2_pq_update(&pq, node_update, NULL);
for(i = 0; i < sizeof(nodes)/sizeof(nodes[0]); ++i) {
for(i = 0; i < (int)(sizeof(nodes)/sizeof(nodes[0])); ++i) {
nd = nghttp2_pq_top(&pq);
CU_ASSERT(ans[i] == nd->key);
nghttp2_pq_pop(&pq);

View File

@ -279,7 +279,7 @@ static ssize_t block_count_send_callback(nghttp2_session* session,
void *user_data)
{
my_user_data *ud = (my_user_data*)user_data;
int r;
ssize_t r;
if(ud->block_count == 0) {
r = NGHTTP2_ERR_WOULDBLOCK;
} else {
@ -388,7 +388,8 @@ void test_nghttp2_session_recv(void)
nghttp2_session_server_new(&session, &callbacks, &user_data);
nghttp2_hd_deflate_init(&deflater);
nvlen = nghttp2_nv_array_copy(&nva, nv, ARRLEN(nv));
nvlen = ARRLEN(nv);
nghttp2_nv_array_copy(&nva, nv, nvlen);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS,
1, NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen);
rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater);
@ -533,7 +534,8 @@ void test_nghttp2_session_recv_invalid_frame(void)
user_data.frame_send_cb_called = 0;
nghttp2_session_server_new(&session, &callbacks, &user_data);
nghttp2_hd_deflate_init(&deflater);
nvlen = nghttp2_nv_array_copy(&nva, nv, ARRLEN(nv));
nvlen = ARRLEN(nv);
nghttp2_nv_array_copy(&nva, nv, nvlen);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 1,
NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen);
rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater);
@ -583,7 +585,7 @@ void test_nghttp2_session_recv_data(void)
nghttp2_session_callbacks callbacks;
my_user_data ud;
uint8_t data[8092];
int rv;
ssize_t rv;
nghttp2_outbound_item *item;
nghttp2_stream *stream;
nghttp2_frame_hd hd;
@ -735,7 +737,8 @@ void test_nghttp2_session_recv_continuation(void)
nghttp2_hd_deflate_init(&deflater);
/* Make 1 HEADERS and insert CONTINUATION header */
nvlen = nghttp2_nv_array_copy(&nva, nv1, ARRLEN(nv1));
nvlen = ARRLEN(nv1);
nghttp2_nv_array_copy(&nva, nv1, nvlen);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_NONE, 1,
NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen);
rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater);
@ -797,7 +800,8 @@ void test_nghttp2_session_recv_continuation(void)
nghttp2_hd_deflate_init(&deflater);
/* HEADERS without END_HEADERS flag */
nvlen = nghttp2_nv_array_copy(&nva, nv1, ARRLEN(nv1));
nvlen = ARRLEN(nv1);
nghttp2_nv_array_copy(&nva, nv1, nvlen);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_NONE, 1,
NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen);
nghttp2_bufs_reset(&bufs);
@ -874,7 +878,8 @@ void test_nghttp2_session_recv_headers_with_priority(void)
open_stream(session, 1);
/* With NGHTTP2_FLAG_PRIORITY without exclusive flag set */
nvlen = nghttp2_nv_array_copy(&nva, nv1, ARRLEN(nv1));
nvlen = ARRLEN(nv1);
nghttp2_nv_array_copy(&nva, nv1, nvlen);
nghttp2_priority_spec_init(&pri_spec, 1, 99, 0);
@ -908,7 +913,8 @@ void test_nghttp2_session_recv_headers_with_priority(void)
/* With NGHTTP2_FLAG_PRIORITY, but cut last 1 byte to make it
invalid. */
nvlen = nghttp2_nv_array_copy(&nva, nv1, ARRLEN(nv1));
nvlen = ARRLEN(nv1);
nghttp2_nv_array_copy(&nva, nv1, nvlen);
nghttp2_priority_spec_init(&pri_spec, 0, 99, 0);
@ -954,7 +960,8 @@ void test_nghttp2_session_recv_headers_with_priority(void)
nghttp2_hd_deflate_init(&deflater);
nvlen = nghttp2_nv_array_copy(&nva, nv1, ARRLEN(nv1));
nvlen = ARRLEN(nv1);
nghttp2_nv_array_copy(&nva, nv1, nvlen);
nghttp2_priority_spec_init(&pri_spec, 1, 0, 0);
@ -1021,7 +1028,8 @@ void test_nghttp2_session_recv_premature_headers(void)
nghttp2_hd_deflate_init(&deflater);
nvlen = nghttp2_nv_array_copy(&nva, nv1, ARRLEN(nv1));
nvlen = ARRLEN(nv1);
nghttp2_nv_array_copy(&nva, nv1, nvlen);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 1,
NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen);
rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater);
@ -1264,7 +1272,8 @@ void test_nghttp2_session_continue(void)
nghttp2_hd_deflate_init(&deflater);
/* Make 2 HEADERS frames */
nvlen = nghttp2_nv_array_copy(&nva, nv1, ARRLEN(nv1));
nvlen = ARRLEN(nv1);
nghttp2_nv_array_copy(&nva, nv1, nvlen);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 1,
NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen);
rv = nghttp2_frame_pack_headers(&bufs, &frame.headers, &deflater);
@ -1280,7 +1289,8 @@ void test_nghttp2_session_continue(void)
framelen1 = nghttp2_buf_len(buf);
databuf.last = nghttp2_cpymem(databuf.last, buf->pos, nghttp2_buf_len(buf));
nvlen = nghttp2_nv_array_copy(&nva, nv2, ARRLEN(nv2));
nvlen = ARRLEN(nv2);
nghttp2_nv_array_copy(&nva, nv2, nvlen);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 3,
NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen);
nghttp2_bufs_reset(&bufs);
@ -1442,7 +1452,8 @@ void test_nghttp2_session_add_frame(void)
CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &user_data));
frame = malloc(sizeof(nghttp2_frame));
nvlen = nghttp2_nv_array_copy(&nva, nv, ARRLEN(nv));
nvlen = ARRLEN(nv);
nghttp2_nv_array_copy(&nva, nv, nvlen);
nghttp2_frame_headers_init(&frame->headers,
NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY,
@ -1536,7 +1547,8 @@ void test_nghttp2_session_on_request_headers_received(void)
/* Check malformed headers. The library accept it. */
nghttp2_session_server_new(&session, &callbacks, &user_data);
nvlen = nghttp2_nv_array_copy(&nva, malformed_nva, ARRLEN(malformed_nva));
nvlen = ARRLEN(malformed_nva);
nghttp2_nv_array_copy(&nva, malformed_nva, nvlen);
nghttp2_frame_headers_init(&frame.headers,
NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY,
1, NGHTTP2_HCAT_HEADERS, NULL, nva, nvlen);
@ -2121,7 +2133,8 @@ void test_nghttp2_session_on_push_promise_received(void)
stream = nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
&pri_spec_default,
NGHTTP2_STREAM_OPENING, NULL);
nvlen = nghttp2_nv_array_copy(&nva, malformed_nva, ARRLEN(malformed_nva));
nvlen = ARRLEN(malformed_nva);
nghttp2_nv_array_copy(&nva, malformed_nva, nvlen);
nghttp2_frame_push_promise_init(&frame.push_promise,
NGHTTP2_FLAG_END_HEADERS, 1, 2,
nva, nvlen);
@ -2386,7 +2399,7 @@ void test_nghttp2_session_send_headers_header_comp_error(void)
nv[i].name = (uint8_t*)"header";
nv[i].namelen = strlen((const char*)nv[i].name);
nv[i].value = malloc(vallen+1);
memset(nv[i].value, '0'+i, vallen);
memset(nv[i].value, '0' + (int)i, vallen);
nv[i].value[vallen] = '\0';
nv[i].valuelen = vallen;
nv[i].flags = NGHTTP2_NV_FLAG_NONE;
@ -2396,7 +2409,8 @@ void test_nghttp2_session_send_headers_header_comp_error(void)
callbacks.send_callback = null_send_callback;
nghttp2_session_client_new(&session, &callbacks, NULL);
nvlen = nghttp2_nv_array_copy(&nva, nv, nnv);
nvlen = nnv;
nghttp2_nv_array_copy(&nva, nv, nvlen);
nghttp2_frame_headers_init(&frame->headers, NGHTTP2_FLAG_END_HEADERS,
session->next_stream_id,
@ -5745,7 +5759,7 @@ void test_nghttp2_session_keep_closed_stream(void)
nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, &iv, 1);
for(i = 0; i < max_concurrent_streams; ++i) {
open_stream(session, i * 2 + 1);
open_stream(session, (int)i * 2 + 1);
}
CU_ASSERT(0 == session->num_closed_streams);

View File

@ -43,7 +43,7 @@ int unpack_framebuf(nghttp2_frame *frame, nghttp2_bufs *bufs)
int unpack_frame(nghttp2_frame *frame, const uint8_t *in, size_t len)
{
ssize_t rv = 0;
int rv = 0;
const uint8_t *payload = in + NGHTTP2_FRAME_HDLEN;
size_t payloadlen = len - NGHTTP2_FRAME_HDLEN;
size_t payloadoff;
@ -187,7 +187,7 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
bp = *buf;
if(offset) {
int n;
ssize_t n;
n = nghttp2_min((ssize_t)offset, nghttp2_buf_len(&bp));
bp.pos += n;