Commit 3931a0b0 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Fix bugs found by coverity scan

parent 70c05584
......@@ -422,7 +422,11 @@ static int server_init(server *serv, const char *node, const char *service)
continue;
}
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, optlen);
rv = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, optlen);
if(rv == -1) {
print_errno("setsockopt", errno);
}
if(bind(fd, rp->ai_addr, rp->ai_addrlen) != 0) {
close(fd);
......@@ -552,8 +556,11 @@ static int handle_timer(io_loop *loop, uint32_t events, void *ptr)
ssize_t nread;
while((nread = read(tmr->fd, buf, sizeof(buf))) == -1 && errno == EINTR);
if(nread == -1) {
break;
}
}
update_date();
......@@ -566,6 +573,7 @@ static int handle_accept(io_loop *loop, uint32_t events, void *ptr)
server *serv = ptr;
int on = 1;
socklen_t optlen = sizeof(on);
int rv;
for(;;) {
connection *conn;
......@@ -574,7 +582,7 @@ static int handle_accept(io_loop *loop, uint32_t events, void *ptr)
errno == EINTR);
if(acfd == -1) {
switch(acfd) {
switch(errno) {
case ENETDOWN:
case EPROTO:
case ENOPROTOOPT:
......@@ -588,7 +596,11 @@ static int handle_accept(io_loop *loop, uint32_t events, void *ptr)
return 0;
}
setsockopt(acfd, IPPROTO_TCP, TCP_NODELAY, &on, optlen);
rv = setsockopt(acfd, IPPROTO_TCP, TCP_NODELAY, &on, optlen);
if(rv == -1) {
print_errno("setsockopt", errno);
}
conn = connection_new(acfd);
......
......@@ -122,6 +122,11 @@ Config::Config()
nghttp2_option_set_recv_client_preface(session_option, 1);
}
Config::~Config()
{
nghttp2_option_del(session_option);
}
Stream::Stream(Http2Handler *handler, int32_t stream_id)
: handler(handler),
rtimer(nullptr),
......@@ -512,7 +517,9 @@ int Http2Handler::on_read()
return -1;
}
evbuffer_drain(input, len);
if(evbuffer_drain(input, len) == -1) {
std::cerr << "evbuffer_drain() failed" << std::endl;
}
}
return send();
......@@ -1268,7 +1275,9 @@ void worker_readcb(bufferevent *bev, void *arg)
auto input = bufferevent_get_input(bev);
while(evbuffer_get_length(input) >= sizeof(ClientInfo)) {
ClientInfo client;
evbuffer_remove(input, &client, sizeof(client));
if(evbuffer_remove(input, &client, sizeof(client)) == -1) {
std::cerr << "evbuffer_remove() failed" << std::endl;
}
sessions->accept_connection(client.fd);
}
}
......
......@@ -80,6 +80,7 @@ struct Config {
bool error_gzip;
bool early_response;
Config();
~Config();
};
class Http2Handler;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment