mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-13 22:37:42 -04:00
Add checks to various return values in unit tests. Found by coverity
This commit is contained in:
parent
6a4ec5c2b5
commit
b9e7329751
@ -70,8 +70,10 @@ read_cb(evutil_socket_t fd, short which, void *arg)
|
|||||||
long idx = (long) arg;
|
long idx = (long) arg;
|
||||||
|
|
||||||
recv(fd, &ch, sizeof(ch), 0);
|
recv(fd, &ch, sizeof(ch), 0);
|
||||||
if (idx >= 0)
|
if (idx >= 0) {
|
||||||
send(idx, "e", 1, 0);
|
if (send(idx, "e", 1, 0) < 0)
|
||||||
|
perror("send");
|
||||||
|
}
|
||||||
fired++;
|
fired++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +114,8 @@ run_once(int num_pipes)
|
|||||||
fired = 0;
|
fired = 0;
|
||||||
|
|
||||||
/* kick everything off with a single write */
|
/* kick everything off with a single write */
|
||||||
send(pipes[1], "e", 1, 0);
|
if (send(pipes[1], "e", 1, 0) < 0)
|
||||||
|
perror("send");
|
||||||
|
|
||||||
event_dispatch();
|
event_dispatch();
|
||||||
|
|
||||||
|
@ -115,11 +115,12 @@ frob_socket(evutil_socket_t sock)
|
|||||||
{
|
{
|
||||||
struct linger l;
|
struct linger l;
|
||||||
int one = 1;
|
int one = 1;
|
||||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one));
|
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&one, sizeof(one))<0)
|
||||||
|
perror("setsockopt(SO_REUSEADDR)");
|
||||||
l.l_onoff = 1;
|
l.l_onoff = 1;
|
||||||
l.l_linger = 0;
|
l.l_linger = 0;
|
||||||
if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (void*)&l, sizeof(l))<0)
|
if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (void*)&l, sizeof(l))<0)
|
||||||
perror("setsockopt");
|
perror("setsockopt(SO_LINGER)");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -104,7 +104,7 @@ test_edgetriggered(void *et)
|
|||||||
|
|
||||||
called = was_et = 0;
|
called = was_et = 0;
|
||||||
|
|
||||||
send(pair[0], test, (int)strlen(test)+1, 0);
|
tt_int_op(send(pair[0], test, (int)strlen(test)+1, 0), >, 0);
|
||||||
shutdown(pair[0], SHUT_WR);
|
shutdown(pair[0], SHUT_WR);
|
||||||
|
|
||||||
/* Initalize the event library */
|
/* Initalize the event library */
|
||||||
|
@ -162,7 +162,7 @@ regress_listener_error(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* send, so that pair[0] will look 'readable'*/
|
/* send, so that pair[0] will look 'readable'*/
|
||||||
send(data->pair[1], "hello", 5, 0);
|
tt_int_op(send(data->pair[1], "hello", 5, 0), >, 0);
|
||||||
|
|
||||||
/* Start a listener with a bogus socket. */
|
/* Start a listener with a bogus socket. */
|
||||||
listener = evconnlistener_new(base, acceptcb, &count,
|
listener = evconnlistener_new(base, acceptcb, &count,
|
||||||
|
@ -179,12 +179,16 @@ regress_dns_server_cb(struct evdns_server_request *req, void *data)
|
|||||||
return;
|
return;
|
||||||
} else if (!strcmp(tab->anstype, "A")) {
|
} else if (!strcmp(tab->anstype, "A")) {
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
evutil_inet_pton(AF_INET, tab->ans, &in);
|
if (!evutil_inet_pton(AF_INET, tab->ans, &in)) {
|
||||||
|
TT_DIE(("Bad A value %s in table", tab->ans));
|
||||||
|
}
|
||||||
evdns_server_request_add_a_reply(req, question, 1, &in.s_addr,
|
evdns_server_request_add_a_reply(req, question, 1, &in.s_addr,
|
||||||
100);
|
100);
|
||||||
} else if (!strcmp(tab->anstype, "AAAA")) {
|
} else if (!strcmp(tab->anstype, "AAAA")) {
|
||||||
struct in6_addr in6;
|
struct in6_addr in6;
|
||||||
evutil_inet_pton(AF_INET6, tab->ans, &in6);
|
if (!evutil_inet_pton(AF_INET6, tab->ans, &in6)) {
|
||||||
|
TT_DIE(("Bad AAAA value %s in table", tab->ans));
|
||||||
|
}
|
||||||
evdns_server_request_add_aaaa_reply(req,
|
evdns_server_request_add_aaaa_reply(req,
|
||||||
question, 1, &in6.s6_addr, 100);
|
question, 1, &in6.s6_addr, 100);
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,7 +106,8 @@ main(int argc, char **argv)
|
|||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
|
|
||||||
send(pair[0], test, (int)strlen(test)+1, 0);
|
if (send(pair[0], test, (int)strlen(test)+1, 0) < 0)
|
||||||
|
return (1);
|
||||||
shutdown(pair[0], SHUT_WR);
|
shutdown(pair[0], SHUT_WR);
|
||||||
|
|
||||||
/* Initalize the event library */
|
/* Initalize the event library */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user