From c41f4139783c58764470345558a6e63749148ee6 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 25 Apr 2015 02:23:01 +0900 Subject: [PATCH] Fix compile error with --enable-werror --- lib/nghttp2_outbound_item.c | 9 +++++++++ lib/nghttp2_outbound_item.h | 7 +++++++ lib/nghttp2_session.c | 19 +++++-------------- lib/nghttp2_session.h | 8 -------- lib/nghttp2_submit.c | 8 ++++---- tests/nghttp2_session_test.c | 18 +++++++++--------- 6 files changed, 34 insertions(+), 35 deletions(-) diff --git a/lib/nghttp2_outbound_item.c b/lib/nghttp2_outbound_item.c index 263dd55d..c4ecab90 100644 --- a/lib/nghttp2_outbound_item.c +++ b/lib/nghttp2_outbound_item.c @@ -25,6 +25,15 @@ #include "nghttp2_outbound_item.h" #include +#include + +void nghttp2_outbound_item_init(nghttp2_outbound_item *item) { + item->cycle = 0; + item->qnext = NULL; + item->queued = 0; + + memset(&item->aux_data, 0, sizeof(nghttp2_aux_data)); +} void nghttp2_outbound_item_free(nghttp2_outbound_item *item, nghttp2_mem *mem) { nghttp2_frame *frame; diff --git a/lib/nghttp2_outbound_item.h b/lib/nghttp2_outbound_item.h index 74164499..110e0577 100644 --- a/lib/nghttp2_outbound_item.h +++ b/lib/nghttp2_outbound_item.h @@ -116,6 +116,13 @@ struct nghttp2_outbound_item { uint8_t queued; }; +/* + * Initializes |item|. No memory allocation is done in this function. + * Don't call nghttp2_outbound_item_free() until frame member is + * initialized. + */ +void nghttp2_outbound_item_init(nghttp2_outbound_item *item); + /* * Deallocates resource for |item|. If |item| is NULL, this function * does nothing. diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index f1e5a6bd..54a3fe6d 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -678,15 +678,6 @@ nghttp2_session_reprioritize_stream(nghttp2_session *session, return 0; } -void nghttp2_session_outbound_item_init(nghttp2_session *session, - nghttp2_outbound_item *item) { - item->cycle = 0; - item->qnext = NULL; - item->queued = 0; - - memset(&item->aux_data, 0, sizeof(nghttp2_aux_data)); -} - int nghttp2_session_add_item(nghttp2_session *session, nghttp2_outbound_item *item) { /* TODO Return error if stream is not found for the frame requiring @@ -820,7 +811,7 @@ int nghttp2_session_add_rst_stream(nghttp2_session *session, int32_t stream_id, return NGHTTP2_ERR_NOMEM; } - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -5955,7 +5946,7 @@ int nghttp2_session_add_ping(nghttp2_session *session, uint8_t flags, return NGHTTP2_ERR_NOMEM; } - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -6004,7 +5995,7 @@ int nghttp2_session_add_goaway(nghttp2_session *session, int32_t last_stream_id, return NGHTTP2_ERR_NOMEM; } - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -6041,7 +6032,7 @@ int nghttp2_session_add_window_update(nghttp2_session *session, uint8_t flags, return NGHTTP2_ERR_NOMEM; } - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -6112,7 +6103,7 @@ int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags, session->inflight_niv = niv; } - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; diff --git a/lib/nghttp2_session.h b/lib/nghttp2_session.h index 25f67895..fb08c652 100644 --- a/lib/nghttp2_session.h +++ b/lib/nghttp2_session.h @@ -280,14 +280,6 @@ typedef struct { int nghttp2_session_is_my_stream_id(nghttp2_session *session, int32_t stream_id); -/* - * Initializes |item|. No memory allocation is done in this function. - * Don't call nghttp2_outbound_item_free() until frame member is - * initialized. - */ -void nghttp2_session_outbound_item_init(nghttp2_session *session, - nghttp2_outbound_item *item); - /* * Adds |item| to the outbound queue in |session|. When this function * succeeds, it takes ownership of |item|. So caller must not free it diff --git a/lib/nghttp2_submit.c b/lib/nghttp2_submit.c index bde78a20..54e8be00 100644 --- a/lib/nghttp2_submit.c +++ b/lib/nghttp2_submit.c @@ -62,7 +62,7 @@ static int32_t submit_headers_shared(nghttp2_session *session, uint8_t flags, goto fail; } - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); if (data_prd != NULL && data_prd->read_callback != NULL) { item->aux_data.headers.data_prd = *data_prd; @@ -212,7 +212,7 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags _U_, return NGHTTP2_ERR_NOMEM; } - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -299,7 +299,7 @@ int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags _U_, return NGHTTP2_ERR_NOMEM; } - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); item->aux_data.headers.stream_user_data = promised_stream_user_data; @@ -453,7 +453,7 @@ int nghttp2_submit_data(nghttp2_session *session, uint8_t flags, return NGHTTP2_ERR_NOMEM; } - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; aux_data = &item->aux_data.data; diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 19722b1c..42ca1e64 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -1627,7 +1627,7 @@ void test_nghttp2_session_add_frame(void) { item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -2698,7 +2698,7 @@ void test_nghttp2_session_send_headers_start_stream(void) { item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -2734,7 +2734,7 @@ void test_nghttp2_session_send_headers_reply(void) { item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -2784,7 +2784,7 @@ void test_nghttp2_session_send_headers_frame_size_error(void) { item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -2829,7 +2829,7 @@ void test_nghttp2_session_send_headers_push_reply(void) { item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -2863,7 +2863,7 @@ void test_nghttp2_session_send_rst_stream(void) { item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -2897,7 +2897,7 @@ void test_nghttp2_session_send_push_promise(void) { item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -2925,7 +2925,7 @@ void test_nghttp2_session_send_push_promise(void) { item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame; @@ -2948,7 +2948,7 @@ void test_nghttp2_session_send_push_promise(void) { &pri_spec_default, NGHTTP2_STREAM_OPENING, NULL); item = mem->malloc(sizeof(nghttp2_outbound_item), NULL); - nghttp2_session_outbound_item_init(session, item); + nghttp2_outbound_item_init(item); frame = &item->frame;