summaryrefslogtreecommitdiff
path: root/src/common/compat_threads.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-06-08 17:30:22 -0400
committerNick Mathewson <nickm@torproject.org>2016-06-08 17:30:22 -0400
commit429d15c5291d9d6668457b7070f8c5fc2c6994e1 (patch)
tree0008d9ccb600a407315c209ab7ba8996d9372f98 /src/common/compat_threads.c
parent3cc374456bc9428fac3ce95203d15ebbe393c09c (diff)
downloadtor-429d15c5291d9d6668457b7070f8c5fc2c6994e1.tar.gz
tor-429d15c5291d9d6668457b7070f8c5fc2c6994e1.zip
Mark the unreachable lines in compat_{,p}threads and workqueue
These are all related to failures from functions that either can't fail as we call them, or where we cannot provoke failure.
Diffstat (limited to 'src/common/compat_threads.c')
-rw-r--r--src/common/compat_threads.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/common/compat_threads.c b/src/common/compat_threads.c
index 8f9001258a..e8450186f8 100644
--- a/src/common/compat_threads.c
+++ b/src/common/compat_threads.c
@@ -63,8 +63,8 @@ tor_cond_t *
tor_cond_new(void)
{
tor_cond_t *cond = tor_malloc(sizeof(tor_cond_t));
- if (tor_cond_init(cond)<0)
- tor_free(cond);
+ if (BUG(tor_cond_init(cond)<0))
+ tor_free(cond); // LCOV_EXCL_LINE
return cond;
}
@@ -242,8 +242,11 @@ alert_sockets_create(alert_sockets_t *socks_out, uint32_t flags)
if (socks[0] >= 0) {
if (fcntl(socks[0], F_SETFD, FD_CLOEXEC) < 0 ||
set_socket_nonblocking(socks[0]) < 0) {
+ // LCOV_EXCL_START -- if eventfd succeeds, fcntl will.
+ tor_assert_nonfatal_unreached();
close(socks[0]);
return -1;
+ // LCOV_EXCL_STOP
}
}
}
@@ -277,9 +280,12 @@ alert_sockets_create(alert_sockets_t *socks_out, uint32_t flags)
fcntl(socks[1], F_SETFD, FD_CLOEXEC) < 0 ||
set_socket_nonblocking(socks[0]) < 0 ||
set_socket_nonblocking(socks[1]) < 0) {
+ // LCOV_EXCL_START -- if pipe succeeds, you can fcntl the output
+ tor_assert_nonfatal_unreached();
close(socks[0]);
close(socks[1]);
return -1;
+ // LCOV_EXCL_STOP
}
socks_out->read_fd = socks[0];
socks_out->write_fd = socks[1];
@@ -294,9 +300,12 @@ alert_sockets_create(alert_sockets_t *socks_out, uint32_t flags)
tor_socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == 0) {
if (set_socket_nonblocking(socks[0]) < 0 ||
set_socket_nonblocking(socks[1])) {
+ // LCOV_EXCL_START -- if socketpair worked, you can make it nonblocking.
+ tor_assert_nonfatal_unreached();
tor_close_socket(socks[0]);
tor_close_socket(socks[1]);
return -1;
+ // LCOV_EXCL_STOP
}
socks_out->read_fd = socks[0];
socks_out->write_fd = socks[1];