diff --git a/lib/nghttp2_frame.c b/lib/nghttp2_frame.c index 90efaff5..210df058 100644 --- a/lib/nghttp2_frame.c +++ b/lib/nghttp2_frame.c @@ -672,6 +672,9 @@ int nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *frame) { nghttp2_buf *buf; nghttp2_ext_altsvc *altsvc; + /* This is required with --disable-assert. */ + (void)rv; + altsvc = frame->payload; buf = &bufs->head->buf; diff --git a/src/h2load_http2_session.cc b/src/h2load_http2_session.cc index f7f63f17..4419fe8e 100644 --- a/src/h2load_http2_session.cc +++ b/src/h2load_http2_session.cc @@ -180,6 +180,9 @@ ssize_t send_callback(nghttp2_session *session, const uint8_t *data, void Http2Session::on_connect() { int rv; + // This is required with --disable-assert. + (void)rv; + nghttp2_session_callbacks *callbacks; nghttp2_session_callbacks_new(&callbacks); diff --git a/src/nghttp.cc b/src/nghttp.cc index 84b0ddda..2aec0eda 100644 --- a/src/nghttp.cc +++ b/src/nghttp.cc @@ -172,6 +172,8 @@ Request::~Request() { nghttp2_gzip_inflate_del(inflater); } void Request::init_inflater() { int rv; + // This is required with --disable-assert. + (void)rv; rv = nghttp2_gzip_inflate_new(&inflater); assert(rv == 0); } diff --git a/src/nghttp2_gzip_test.c b/src/nghttp2_gzip_test.c index 4255caa9..7ad3c8d2 100644 --- a/src/nghttp2_gzip_test.c +++ b/src/nghttp2_gzip_test.c @@ -43,14 +43,14 @@ static size_t deflate_data(uint8_t *out, size_t outlen, const uint8_t *in, zst.opaque = Z_NULL; rv = deflateInit(&zst, Z_DEFAULT_COMPRESSION); - assert(rv == Z_OK); + CU_ASSERT(rv == Z_OK); zst.avail_in = (unsigned int)inlen; zst.next_in = (uint8_t *)in; zst.avail_out = (unsigned int)outlen; zst.next_out = out; rv = deflate(&zst, Z_SYNC_FLUSH); - assert(rv == Z_OK); + CU_ASSERT(rv == Z_OK); deflateEnd(&zst); diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index c33f8c51..d1e44f16 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -3613,6 +3613,7 @@ StringRef strproto(shrpx_proto proto) { // gcc needs this. assert(0); + abort(); } namespace { diff --git a/src/shrpx_config_test.cc b/src/shrpx_config_test.cc index bc168b40..75319712 100644 --- a/src/shrpx_config_test.cc +++ b/src/shrpx_config_test.cc @@ -163,14 +163,14 @@ void test_shrpx_config_parse_log_format(void) { void test_shrpx_config_read_tls_ticket_key_file(void) { char file1[] = "/tmp/nghttpx-unittest.XXXXXX"; auto fd1 = mkstemp(file1); - assert(fd1 != -1); - assert(48 == - write(fd1, "0..............12..............34..............5", 48)); + CU_ASSERT(fd1 != -1); + CU_ASSERT(48 == + write(fd1, "0..............12..............34..............5", 48)); char file2[] = "/tmp/nghttpx-unittest.XXXXXX"; auto fd2 = mkstemp(file2); - assert(fd2 != -1); - assert(48 == - write(fd2, "6..............78..............9a..............b", 48)); + CU_ASSERT(fd2 != -1); + CU_ASSERT(48 == + write(fd2, "6..............78..............9a..............b", 48)); close(fd1); close(fd2); @@ -204,16 +204,18 @@ void test_shrpx_config_read_tls_ticket_key_file(void) { void test_shrpx_config_read_tls_ticket_key_file_aes_256(void) { char file1[] = "/tmp/nghttpx-unittest.XXXXXX"; auto fd1 = mkstemp(file1); - assert(fd1 != -1); - assert(80 == write(fd1, "0..............12..............................34..." - "...........................5", - 80)); + CU_ASSERT(fd1 != -1); + CU_ASSERT(80 == write(fd1, + "0..............12..............................34..." + "...........................5", + 80)); char file2[] = "/tmp/nghttpx-unittest.XXXXXX"; auto fd2 = mkstemp(file2); - assert(fd2 != -1); - assert(80 == write(fd2, "6..............78..............................9a..." - "...........................b", - 80)); + CU_ASSERT(fd2 != -1); + CU_ASSERT(80 == write(fd2, + "6..............78..............................9a..." + "...........................b", + 80)); close(fd1); close(fd2); diff --git a/src/shrpx_dns_resolver.cc b/src/shrpx_dns_resolver.cc index 356fd970..cb77e604 100644 --- a/src/shrpx_dns_resolver.cc +++ b/src/shrpx_dns_resolver.cc @@ -204,6 +204,7 @@ int DNSResolver::handle_event(int rfd, int wfd) { default: // Unreachable assert(0); + abort(); } } diff --git a/src/shrpx_dns_tracker.cc b/src/shrpx_dns_tracker.cc index 9eeca5d8..1ab368e3 100644 --- a/src/shrpx_dns_tracker.cc +++ b/src/shrpx_dns_tracker.cc @@ -250,6 +250,7 @@ int DNSTracker::resolve(Address *result, DNSQuery *dnsq) { return DNS_STATUS_OK; default: assert(0); + abort(); } } diff --git a/src/shrpx_downstream_queue.cc b/src/shrpx_downstream_queue.cc index f7f66b7d..74465396 100644 --- a/src/shrpx_downstream_queue.cc +++ b/src/shrpx_downstream_queue.cc @@ -158,6 +158,8 @@ Downstream *DownstreamQueue::remove_and_get_blocked(Downstream *downstream, auto next_downstream = link->downstream; auto link2 = next_downstream->detach_blocked_link(); + // This is required with --disable-assert. + (void)link2; assert(link2 == link); ent.blocked.remove(link); delete link; diff --git a/src/shrpx_http2_session.cc b/src/shrpx_http2_session.cc index 56876738..539edfed 100644 --- a/src/shrpx_http2_session.cc +++ b/src/shrpx_http2_session.cc @@ -334,6 +334,7 @@ int Http2Session::resolve_name() { return 0; default: assert(0); + abort(); } } @@ -2115,7 +2116,10 @@ int Http2Session::write_tls() { for (;;) { if (wb_.rleft() > 0) { auto iovcnt = wb_.riovec(&iov, 1); - assert(iovcnt == 1); + if (iovcnt != 1) { + assert(0); + return -1; + } auto nwrite = conn_.write_tls(iov.iov_base, iov.iov_len); if (nwrite == 0) { diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index 561fcbe3..03b8f771 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -1307,7 +1307,10 @@ int HttpDownstreamConnection::write_tls() { while (input->rleft() > 0) { auto iovcnt = input->riovec(&iov, 1); - assert(iovcnt == 1); + if (iovcnt != 1) { + assert(0); + return -1; + } auto nwrite = conn_.write_tls(iov.iov_base, iov.iov_len); if (nwrite == 0) { diff --git a/src/shrpx_live_check.cc b/src/shrpx_live_check.cc index 4203b0ae..863ffa51 100644 --- a/src/shrpx_live_check.cc +++ b/src/shrpx_live_check.cc @@ -478,7 +478,10 @@ int LiveCheck::write_tls() { for (;;) { if (wb_.rleft() > 0) { auto iovcnt = wb_.riovec(&iov, 1); - assert(iovcnt == 1); + if (iovcnt != 1) { + assert(0); + return -1; + } auto nwrite = conn_.write_tls(iov.iov_base, iov.iov_len); if (nwrite == 0) { @@ -544,7 +547,10 @@ int LiveCheck::write_clear() { for (;;) { if (wb_.rleft() > 0) { auto iovcnt = wb_.riovec(&iov, 1); - assert(iovcnt == 1); + if (iovcnt != 1) { + assert(0); + return -1; + } auto nwrite = conn_.write_clear(iov.iov_base, iov.iov_len); if (nwrite == 0) {