Fix coverity warnings in benchmark tools.

Again, not harmful, but best to stay warning-free.
This commit is contained in:
Nick Mathewson 2014-01-08 11:54:56 -05:00
parent 867f401f9b
commit ff7f739685
2 changed files with 12 additions and 3 deletions

View File

@ -60,7 +60,7 @@
#include <event.h>
#include <evutil.h>
static int count, writes, fired;
static int count, writes, fired, failures;
static evutil_socket_t *pipes;
static int num_pipes, num_active, num_writes;
static struct event *events;
@ -71,12 +71,19 @@ read_cb(evutil_socket_t fd, short which, void *arg)
{
ev_intptr_t idx = (ev_intptr_t) arg, widx = idx + 1;
u_char ch;
ev_ssize_t n;
count += recv(fd, (char*)&ch, sizeof(ch), 0);
n = recv(fd, (char*)&ch, sizeof(ch), 0);
if (n >= 0)
count += n;
else
failures++
if (writes) {
if (widx >= num_pipes)
widx -= num_pipes;
(void) send(pipes[2 * widx + 1], "e", 1, 0);
n = send(pipes[2 * widx + 1], "e", 1, 0);
if (n != 1)
failures++
writes--;
fired++;
}

View File

@ -178,10 +178,12 @@ main(int argc, char **argv)
evhttp_bind_socket(http, "0.0.0.0", port);
#ifdef _WIN32
if (use_iocp) {
struct timeval tv={99999999,0};
event_base_loopexit(base, &tv);
}
#endif
event_base_dispatch(base);
/* NOTREACHED */