From d960cf895343190e0df4f795aa254cd9bc5aadad Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 3 Sep 2013 21:24:14 +0900 Subject: [PATCH] Add const to read-only nghttp2_frame* parameter in callbacks --- examples/client.c | 10 +++++----- lib/includes/nghttp2/nghttp2.h | 12 ++++++------ src/HttpServer.cc | 4 ++-- src/app_helper.cc | 8 ++++---- src/app_helper.h | 6 +++--- src/nghttp.cc | 6 +++--- src/shrpx_http2_upstream.cc | 4 ++-- src/shrpx_spdy_session.cc | 8 ++++---- tests/nghttp2_session_test.c | 12 ++++++------ 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/examples/client.c b/examples/client.c index 5196687f..6fc2f9e7 100644 --- a/examples/client.c +++ b/examples/client.c @@ -228,7 +228,7 @@ static ssize_t recv_callback(nghttp2_session *session, * (nghttp2_submit_request). */ static int before_frame_send_callback(nghttp2_session *session, - nghttp2_frame *frame, + const nghttp2_frame *frame, void *user_data) { if(frame->hd.type == NGHTTP2_HEADERS && @@ -245,7 +245,7 @@ static int before_frame_send_callback(nghttp2_session *session, } static int on_frame_send_callback(nghttp2_session *session, - nghttp2_frame *frame, void *user_data) + const nghttp2_frame *frame, void *user_data) { size_t i; switch(frame->hd.type) { @@ -272,7 +272,7 @@ static int on_frame_send_callback(nghttp2_session *session, } static int on_frame_recv_callback(nghttp2_session *session, - nghttp2_frame *frame, void *user_data) + const nghttp2_frame *frame, void *user_data) { size_t i; switch(frame->hd.type) { @@ -311,8 +311,8 @@ static int on_frame_recv_callback(nghttp2_session *session, */ static int on_stream_close_callback(nghttp2_session *session, int32_t stream_id, - nghttp2_error_code error_code, - void *user_data) + nghttp2_error_code error_code, + void *user_data) { struct Request *req; req = nghttp2_session_get_stream_user_data(session, stream_id); diff --git a/lib/includes/nghttp2/nghttp2.h b/lib/includes/nghttp2/nghttp2.h index 9e582403..eaeac330 100644 --- a/lib/includes/nghttp2/nghttp2.h +++ b/lib/includes/nghttp2/nghttp2.h @@ -786,7 +786,7 @@ typedef ssize_t (*nghttp2_recv_callback) * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. */ typedef int (*nghttp2_on_frame_recv_callback) -(nghttp2_session *session, nghttp2_frame *frame, void *user_data); +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data); /** * @functypedef @@ -803,8 +803,8 @@ typedef int (*nghttp2_on_frame_recv_callback) * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. */ typedef int (*nghttp2_on_invalid_frame_recv_callback) -(nghttp2_session *session, nghttp2_frame *frame, nghttp2_error_code error_code, - void *user_data); +(nghttp2_session *session, const nghttp2_frame *frame, + nghttp2_error_code error_code, void *user_data); /** * @functypedef @@ -857,7 +857,7 @@ typedef int (*nghttp2_on_data_recv_callback) * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. */ typedef int (*nghttp2_before_frame_send_callback) -(nghttp2_session *session, nghttp2_frame *frame, void *user_data); +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data); /** * @functypedef @@ -870,7 +870,7 @@ typedef int (*nghttp2_before_frame_send_callback) * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. */ typedef int (*nghttp2_on_frame_send_callback) -(nghttp2_session *session, nghttp2_frame *frame, void *user_data); +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data); /** * @functypedef @@ -886,7 +886,7 @@ typedef int (*nghttp2_on_frame_send_callback) * immediately return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. */ typedef int (*nghttp2_on_frame_not_send_callback) -(nghttp2_session *session, nghttp2_frame *frame, int lib_error_code, +(nghttp2_session *session, const nghttp2_frame *frame, int lib_error_code, void *user_data); /** diff --git a/src/HttpServer.cc b/src/HttpServer.cc index e7eb58b6..28aad538 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -686,7 +686,7 @@ const char *REQUIRED_HEADERS[] = { namespace { int hd_on_frame_recv_callback -(nghttp2_session *session, nghttp2_frame *frame, void *user_data) +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { auto hd = reinterpret_cast(user_data); if(hd->get_config()->verbose) { @@ -741,7 +741,7 @@ int htdocs_on_request_recv_callback namespace { int hd_on_frame_send_callback -(nghttp2_session *session, nghttp2_frame *frame, +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { auto hd = reinterpret_cast(user_data); diff --git a/src/app_helper.cc b/src/app_helper.cc index aff71857..9035c3e4 100644 --- a/src/app_helper.cc +++ b/src/app_helper.cc @@ -235,7 +235,7 @@ const char* frame_name_ansi_esc(print_type ptype) } // namespace namespace { -void print_frame(print_type ptype, nghttp2_frame *frame) +void print_frame(print_type ptype, const nghttp2_frame *frame) { printf("%s%s%s frame ", frame_name_ansi_esc(ptype), @@ -324,7 +324,7 @@ void print_frame(print_type ptype, nghttp2_frame *frame) } // namespace int on_frame_recv_callback -(nghttp2_session *session, nghttp2_frame *frame, void *user_data) +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { print_timer(); printf(" recv "); @@ -334,7 +334,7 @@ int on_frame_recv_callback } int on_invalid_frame_recv_callback -(nghttp2_session *session, nghttp2_frame *frame, +(nghttp2_session *session, const nghttp2_frame *frame, nghttp2_error_code error_code, void *user_data) { print_timer(); @@ -392,7 +392,7 @@ int on_unknown_frame_recv_callback(nghttp2_session *session, } int on_frame_send_callback -(nghttp2_session *session, nghttp2_frame *frame, void *user_data) +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { print_timer(); printf(" send "); diff --git a/src/app_helper.h b/src/app_helper.h index bf331771..6860e433 100644 --- a/src/app_helper.h +++ b/src/app_helper.h @@ -40,10 +40,10 @@ namespace nghttp2 { void print_nv(char **nv); int on_frame_recv_callback -(nghttp2_session *session, nghttp2_frame *frame, void *user_data); +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data); int on_invalid_frame_recv_callback -(nghttp2_session *session, nghttp2_frame *frame, +(nghttp2_session *session, const nghttp2_frame *frame, nghttp2_error_code error_code, void *user_data); int on_frame_recv_parse_error_callback(nghttp2_session *session, @@ -62,7 +62,7 @@ int on_unknown_frame_recv_callback(nghttp2_session *session, void *user_data); int on_frame_send_callback -(nghttp2_session *session, nghttp2_frame *frame, void *user_data); +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data); int on_data_recv_callback (nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id, diff --git a/src/nghttp.cc b/src/nghttp.cc index 3317e6b0..a689920c 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -979,7 +979,7 @@ void check_stream_id(nghttp2_session *session, int32_t stream_id, } // namespace int on_frame_send_callback2 -(nghttp2_session *session, nghttp2_frame *frame, void *user_data) +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { if(frame->hd.type == NGHTTP2_HEADERS && frame->headers.cat == NGHTTP2_HCAT_REQUEST) { @@ -992,7 +992,7 @@ int on_frame_send_callback2 } void check_response_header -(nghttp2_session *session, nghttp2_frame *frame, void *user_data) +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { if(frame->hd.type != NGHTTP2_HEADERS || frame->headers.cat != NGHTTP2_HCAT_RESPONSE) { @@ -1027,7 +1027,7 @@ void check_response_header } int on_frame_recv_callback2 -(nghttp2_session *session, nghttp2_frame *frame, void *user_data) +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { if(frame->hd.type == NGHTTP2_HEADERS && frame->headers.cat == NGHTTP2_HCAT_RESPONSE) { diff --git a/src/shrpx_http2_upstream.cc b/src/shrpx_http2_upstream.cc index 78a41305..ee19496d 100644 --- a/src/shrpx_http2_upstream.cc +++ b/src/shrpx_http2_upstream.cc @@ -174,7 +174,7 @@ int Http2Upstream::upgrade_upstream(HttpsUpstream *http) namespace { int on_frame_recv_callback -(nghttp2_session *session, nghttp2_frame *frame, void *user_data) +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { auto upstream = reinterpret_cast(user_data); switch(frame->hd.type) { @@ -332,7 +332,7 @@ int on_data_chunk_recv_callback(nghttp2_session *session, namespace { int on_frame_not_send_callback(nghttp2_session *session, - nghttp2_frame *frame, + const nghttp2_frame *frame, int lib_error_code, void *user_data) { auto upstream = reinterpret_cast(user_data); diff --git a/src/shrpx_spdy_session.cc b/src/shrpx_spdy_session.cc index 3d3bae6e..6393b38a 100644 --- a/src/shrpx_spdy_session.cc +++ b/src/shrpx_spdy_session.cc @@ -724,7 +724,7 @@ int on_stream_close_callback namespace { int on_frame_recv_callback -(nghttp2_session *session, nghttp2_frame *frame, void *user_data) +(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) { int rv; auto spdy = reinterpret_cast(user_data); @@ -947,7 +947,7 @@ int on_data_chunk_recv_callback(nghttp2_session *session, namespace { int before_frame_send_callback(nghttp2_session *session, - nghttp2_frame *frame, + const nghttp2_frame *frame, void *user_data) { if(frame->hd.type == NGHTTP2_HEADERS && @@ -972,8 +972,8 @@ int before_frame_send_callback(nghttp2_session *session, namespace { int on_frame_not_send_callback(nghttp2_session *session, - nghttp2_frame *frame, - int lib_error_code, void *user_data) + const nghttp2_frame *frame, + int lib_error_code, void *user_data) { auto spdy = reinterpret_cast(user_data); SSLOG(WARNING, spdy) << "Failed to send control frame type=" diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 92c92031..37b5be77 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -109,8 +109,8 @@ static ssize_t scripted_recv_callback(nghttp2_session *session, } static ssize_t eof_recv_callback(nghttp2_session *session, - uint8_t* data, size_t len, int flags, - void *user_data) + uint8_t* data, size_t len, int flags, + void *user_data) { return NGHTTP2_ERR_EOF; } @@ -127,7 +127,7 @@ static ssize_t accumulator_send_callback(nghttp2_session *session, } static int on_frame_recv_callback(nghttp2_session *session, - nghttp2_frame *frame, + const nghttp2_frame *frame, void *user_data) { my_user_data *ud = (my_user_data*)user_data; @@ -136,7 +136,7 @@ static int on_frame_recv_callback(nghttp2_session *session, } static int on_invalid_frame_recv_callback(nghttp2_session *session, - nghttp2_frame *frame, + const nghttp2_frame *frame, nghttp2_error_code error_code, void *user_data) { @@ -146,7 +146,7 @@ static int on_invalid_frame_recv_callback(nghttp2_session *session, } static int on_frame_send_callback(nghttp2_session *session, - nghttp2_frame *frame, + const nghttp2_frame *frame, void *user_data) { my_user_data *ud = (my_user_data*)user_data; @@ -156,7 +156,7 @@ static int on_frame_send_callback(nghttp2_session *session, } static int on_frame_not_send_callback(nghttp2_session *session, - nghttp2_frame *frame, + const nghttp2_frame *frame, int lib_error, void *user_data) {