]> granicus.if.org Git - libevent/commitdiff
Fix coverity warnings in benchmark tools.
authorNick Mathewson <nickm@torproject.org>
Wed, 8 Jan 2014 16:54:56 +0000 (11:54 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 8 Jan 2014 16:54:56 +0000 (11:54 -0500)
Again, not harmful, but best to stay warning-free.

test/bench.c
test/bench_http.c

index b3e40a555192e4eadbe8f0da381e5957026307fa..b4f78209823c36b01320cc696d5464c4fae6a5a8 100644 (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++;
        }
index 09f521b5c49c0eee3e3c37f1d4777e5e4d9214e9..801fd2a6e4b4d825dce5c3075a6388be294c7b24 100644 (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 */