From ff7f739685152dfda96acdf804491436367fc581 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 8 Jan 2014 11:54:56 -0500 Subject: [PATCH] Fix coverity warnings in benchmark tools. Again, not harmful, but best to stay warning-free. --- test/bench.c | 13 ++++++++++--- test/bench_http.c | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/bench.c b/test/bench.c index b3e40a55..b4f78209 100644 --- a/test/bench.c +++ b/test/bench.c @@ -60,7 +60,7 @@ #include #include -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++; } diff --git a/test/bench_http.c b/test/bench_http.c index 09f521b5..801fd2a6 100644 --- a/test/bench_http.c +++ b/test/bench_http.c @@ -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 */ -- 2.50.1