Code cleanup

This commit is contained in:
Tatsuhiro Tsujikawa 2014-10-30 23:31:28 +09:00
parent 49b8d1d88c
commit 7d282cd0bd
5 changed files with 23 additions and 22 deletions

View File

@ -999,7 +999,7 @@ static int deflate_nv(nghttp2_hd_deflater *deflater,
{ {
int rv; int rv;
search_result res; search_result res;
ssize_t idx = -1; ssize_t idx;
int incidx = 0; int incidx = 0;
uint32_t name_hash = hash(nv->name, nv->namelen); uint32_t name_hash = hash(nv->name, nv->namelen);
uint32_t value_hash = hash(nv->value, nv->valuelen); uint32_t value_hash = hash(nv->value, nv->valuelen);

View File

@ -1511,7 +1511,7 @@ static int session_headers_add_pad(nghttp2_session *session,
padlen = padded_payloadlen - frame->hd.length; padlen = padded_payloadlen - frame->hd.length;
DEBUGF(fprintf(stderr, DEBUGF(fprintf(stderr,
"send: padding selected: payloadlen=%zu, padlen=%zu\n", "send: padding selected: payloadlen=%zd, padlen=%zu\n",
padded_payloadlen, padlen)); padded_payloadlen, padlen));
rv = nghttp2_frame_add_pad(framebufs, &frame->hd, padlen); rv = nghttp2_frame_add_pad(framebufs, &frame->hd, padlen);
@ -1784,9 +1784,9 @@ static int session_prep_frame(nghttp2_session *session,
rv = nghttp2_session_predicate_data_send(session, frame->hd.stream_id); rv = nghttp2_session_predicate_data_send(session, frame->hd.stream_id);
if(rv != 0) { if(rv != 0) {
if(stream) {
int rv2; int rv2;
if(stream) {
rv2 = nghttp2_stream_detach_data(stream, &session->ob_da_pq, rv2 = nghttp2_stream_detach_data(stream, &session->ob_da_pq,
session->last_cycle); session->last_cycle);
@ -5389,7 +5389,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
} }
} }
DEBUGF(fprintf(stderr, "recv: data_readlen=%zu\n", data_readlen)); DEBUGF(fprintf(stderr, "recv: data_readlen=%zd\n", data_readlen));
if(stream && data_readlen > 0 && if(stream && data_readlen > 0 &&
session->callbacks.on_data_chunk_recv_callback) { session->callbacks.on_data_chunk_recv_callback) {
@ -5815,7 +5815,7 @@ int nghttp2_session_pack_data(nghttp2_session *session,
use safe limit. */ use safe limit. */
payloadlen = datamax; payloadlen = datamax;
DEBUGF(fprintf(stderr, "send: use safe limit payloadlen=%zu", DEBUGF(fprintf(stderr, "send: use safe limit payloadlen=%zd",
payloadlen)); payloadlen));
} else { } else {
assert(&session->aob.framebufs == bufs); assert(&session->aob.framebufs == bufs);

View File

@ -674,7 +674,6 @@ int Http2Handler::submit_non_final_response(const std::string& status,
int Http2Handler::submit_push_promise(Stream *stream, int Http2Handler::submit_push_promise(Stream *stream,
const std::string& push_path) const std::string& push_path)
{ {
std::string authority;
auto itr = std::lower_bound(std::begin(stream->headers), auto itr = std::lower_bound(std::begin(stream->headers),
std::end(stream->headers), std::end(stream->headers),
Header(":authority", "")); Header(":authority", ""));

View File

@ -79,7 +79,7 @@ static void to_hex(char *dest, const uint8_t *src, size_t len)
static void output_to_json(nghttp2_hd_deflater *deflater, static void output_to_json(nghttp2_hd_deflater *deflater,
nghttp2_bufs *bufs, size_t inputlen, nghttp2_bufs *bufs, size_t inputlen,
const std::vector<nghttp2_nv> nva, const std::vector<nghttp2_nv>& nva,
int seq) int seq)
{ {
auto len = nghttp2_bufs_len(bufs); auto len = nghttp2_bufs_len(bufs);

View File

@ -1122,8 +1122,8 @@ int on_data_chunk_recv_callback
const uint8_t *data, size_t len, void *user_data) const uint8_t *data, size_t len, void *user_data)
{ {
auto client = get_session(user_data); auto client = get_session(user_data);
auto req = auto req = static_cast<Request*>
(Request*)nghttp2_session_get_stream_user_data(session, stream_id); (nghttp2_session_get_stream_user_data(session, stream_id));
if(!req) { if(!req) {
return 0; return 0;
@ -1301,8 +1301,8 @@ int on_header_callback(nghttp2_session *session,
switch(frame->hd.type) { switch(frame->hd.type) {
case NGHTTP2_HEADERS: { case NGHTTP2_HEADERS: {
auto req = (Request*)nghttp2_session_get_stream_user_data auto req = static_cast<Request*>
(session, frame->hd.stream_id); (nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if(!req) { if(!req) {
break; break;
@ -1330,8 +1330,9 @@ int on_header_callback(nghttp2_session *session,
break; break;
} }
case NGHTTP2_PUSH_PROMISE: { case NGHTTP2_PUSH_PROMISE: {
auto req = (Request*)nghttp2_session_get_stream_user_data auto req = static_cast<Request*>
(session, frame->push_promise.promised_stream_id); (nghttp2_session_get_stream_user_data
(session, frame->push_promise.promised_stream_id));
if(!req) { if(!req) {
break; break;
@ -1369,8 +1370,8 @@ int on_frame_recv_callback2
auto client = get_session(user_data); auto client = get_session(user_data);
switch(frame->hd.type) { switch(frame->hd.type) {
case NGHTTP2_HEADERS: { case NGHTTP2_HEADERS: {
auto req = (Request*)nghttp2_session_get_stream_user_data auto req = static_cast<Request*>
(session, frame->hd.stream_id); (nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
// If this is the HTTP Upgrade with OPTIONS method to avoid POST, // If this is the HTTP Upgrade with OPTIONS method to avoid POST,
// req is nullptr. // req is nullptr.
if(!req) { if(!req) {
@ -1414,8 +1415,9 @@ int on_frame_recv_callback2
} }
break; break;
case NGHTTP2_PUSH_PROMISE: { case NGHTTP2_PUSH_PROMISE: {
auto req = (Request*)nghttp2_session_get_stream_user_data auto req = static_cast<Request*>
(session, frame->push_promise.promised_stream_id); (nghttp2_session_get_stream_user_data
(session, frame->push_promise.promised_stream_id));
if(!req) { if(!req) {
break; break;
} }
@ -1472,8 +1474,8 @@ int on_stream_close_callback
void *user_data) void *user_data)
{ {
auto client = get_session(user_data); auto client = get_session(user_data);
auto req = auto req = static_cast<Request*>
(Request*)nghttp2_session_get_stream_user_data(session, stream_id); (nghttp2_session_get_stream_user_data(session, stream_id));
if(!req) { if(!req) {
return 0; return 0;
@ -1798,8 +1800,8 @@ ssize_t file_read_callback
uint8_t *buf, size_t length, uint32_t *data_flags, uint8_t *buf, size_t length, uint32_t *data_flags,
nghttp2_data_source *source, void *user_data) nghttp2_data_source *source, void *user_data)
{ {
auto req = (Request*)nghttp2_session_get_stream_user_data auto req = static_cast<Request*>
(session, stream_id); (nghttp2_session_get_stream_user_data(session, stream_id));
assert(req); assert(req);
int fd = source->fd; int fd = source->fd;
ssize_t nread; ssize_t nread;