src: Fix error reported by coverity scan

This commit is contained in:
Tatsuhiro Tsujikawa 2015-02-11 23:20:13 +09:00
parent ae0100a9ab
commit 364772f508
3 changed files with 13 additions and 6 deletions

View File

@ -83,6 +83,9 @@ int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
auto client = static_cast<Client *>(user_data);
auto req_stat = static_cast<RequestStat *>(
nghttp2_session_get_stream_user_data(session, stream_id));
if (!req_stat) {
return 0;
}
client->on_stream_close(stream_id, error_code == NGHTTP2_NO_ERROR, req_stat);
return 0;
}
@ -100,6 +103,7 @@ int before_frame_send_callback(nghttp2_session *session,
client->on_request(frame->hd.stream_id);
auto req_stat = static_cast<RequestStat *>(
nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
assert(req_stat);
client->record_request_time(req_stat);
return 0;

View File

@ -1825,6 +1825,7 @@ int before_frame_send_callback(nghttp2_session *session,
}
auto req = static_cast<Request *>(
nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
assert(req);
req->record_request_time();
return 0;
}

View File

@ -253,12 +253,13 @@ ssize_t Connection::read_tls(void *data, size_t len) {
}
ssize_t Connection::write_clear(const void *data, size_t len) {
ssize_t nwrite = std::min(len, wlimit.avail());
if (nwrite == 0) {
len = std::min(len, wlimit.avail());
if (len == 0) {
return 0;
}
while ((nwrite = write(fd, data, nwrite)) == -1 && errno == EINTR)
ssize_t nwrite;
while ((nwrite = write(fd, data, len)) == -1 && errno == EINTR)
;
if (nwrite == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
@ -298,12 +299,13 @@ ssize_t Connection::writev_clear(struct iovec *iov, int iovcnt) {
}
ssize_t Connection::read_clear(void *data, size_t len) {
ssize_t nread = std::min(len, rlimit.avail());
if (nread == 0) {
len = std::min(len, rlimit.avail());
if (len == 0) {
return 0;
}
while ((nread = read(fd, data, nread)) == -1 && errno == EINTR)
ssize_t nread;
while ((nread = read(fd, data, len)) == -1 && errno == EINTR)
;
if (nread == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {