Merge pull request #923 from nghttp2/compile-with-disable-assert

Compile with --disable-assert
This commit is contained in:
Tatsuhiro Tsujikawa 2017-05-18 23:49:41 +09:00 committed by GitHub
commit 7d111d9963
12 changed files with 48 additions and 20 deletions

View File

@ -672,6 +672,9 @@ int nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *frame) {
nghttp2_buf *buf; nghttp2_buf *buf;
nghttp2_ext_altsvc *altsvc; nghttp2_ext_altsvc *altsvc;
/* This is required with --disable-assert. */
(void)rv;
altsvc = frame->payload; altsvc = frame->payload;
buf = &bufs->head->buf; buf = &bufs->head->buf;

View File

@ -180,6 +180,9 @@ ssize_t send_callback(nghttp2_session *session, const uint8_t *data,
void Http2Session::on_connect() { void Http2Session::on_connect() {
int rv; int rv;
// This is required with --disable-assert.
(void)rv;
nghttp2_session_callbacks *callbacks; nghttp2_session_callbacks *callbacks;
nghttp2_session_callbacks_new(&callbacks); nghttp2_session_callbacks_new(&callbacks);

View File

@ -172,6 +172,8 @@ Request::~Request() { nghttp2_gzip_inflate_del(inflater); }
void Request::init_inflater() { void Request::init_inflater() {
int rv; int rv;
// This is required with --disable-assert.
(void)rv;
rv = nghttp2_gzip_inflate_new(&inflater); rv = nghttp2_gzip_inflate_new(&inflater);
assert(rv == 0); assert(rv == 0);
} }

View File

@ -43,14 +43,14 @@ static size_t deflate_data(uint8_t *out, size_t outlen, const uint8_t *in,
zst.opaque = Z_NULL; zst.opaque = Z_NULL;
rv = deflateInit(&zst, Z_DEFAULT_COMPRESSION); rv = deflateInit(&zst, Z_DEFAULT_COMPRESSION);
assert(rv == Z_OK); CU_ASSERT(rv == Z_OK);
zst.avail_in = (unsigned int)inlen; zst.avail_in = (unsigned int)inlen;
zst.next_in = (uint8_t *)in; zst.next_in = (uint8_t *)in;
zst.avail_out = (unsigned int)outlen; zst.avail_out = (unsigned int)outlen;
zst.next_out = out; zst.next_out = out;
rv = deflate(&zst, Z_SYNC_FLUSH); rv = deflate(&zst, Z_SYNC_FLUSH);
assert(rv == Z_OK); CU_ASSERT(rv == Z_OK);
deflateEnd(&zst); deflateEnd(&zst);

View File

@ -3622,6 +3622,7 @@ StringRef strproto(shrpx_proto proto) {
// gcc needs this. // gcc needs this.
assert(0); assert(0);
abort();
} }
namespace { namespace {

View File

@ -163,14 +163,14 @@ void test_shrpx_config_parse_log_format(void) {
void test_shrpx_config_read_tls_ticket_key_file(void) { void test_shrpx_config_read_tls_ticket_key_file(void) {
char file1[] = "/tmp/nghttpx-unittest.XXXXXX"; char file1[] = "/tmp/nghttpx-unittest.XXXXXX";
auto fd1 = mkstemp(file1); auto fd1 = mkstemp(file1);
assert(fd1 != -1); CU_ASSERT(fd1 != -1);
assert(48 == CU_ASSERT(48 ==
write(fd1, "0..............12..............34..............5", 48)); write(fd1, "0..............12..............34..............5", 48));
char file2[] = "/tmp/nghttpx-unittest.XXXXXX"; char file2[] = "/tmp/nghttpx-unittest.XXXXXX";
auto fd2 = mkstemp(file2); auto fd2 = mkstemp(file2);
assert(fd2 != -1); CU_ASSERT(fd2 != -1);
assert(48 == CU_ASSERT(48 ==
write(fd2, "6..............78..............9a..............b", 48)); write(fd2, "6..............78..............9a..............b", 48));
close(fd1); close(fd1);
close(fd2); 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) { void test_shrpx_config_read_tls_ticket_key_file_aes_256(void) {
char file1[] = "/tmp/nghttpx-unittest.XXXXXX"; char file1[] = "/tmp/nghttpx-unittest.XXXXXX";
auto fd1 = mkstemp(file1); auto fd1 = mkstemp(file1);
assert(fd1 != -1); CU_ASSERT(fd1 != -1);
assert(80 == write(fd1, "0..............12..............................34..." CU_ASSERT(80 == write(fd1,
"...........................5", "0..............12..............................34..."
80)); "...........................5",
80));
char file2[] = "/tmp/nghttpx-unittest.XXXXXX"; char file2[] = "/tmp/nghttpx-unittest.XXXXXX";
auto fd2 = mkstemp(file2); auto fd2 = mkstemp(file2);
assert(fd2 != -1); CU_ASSERT(fd2 != -1);
assert(80 == write(fd2, "6..............78..............................9a..." CU_ASSERT(80 == write(fd2,
"...........................b", "6..............78..............................9a..."
80)); "...........................b",
80));
close(fd1); close(fd1);
close(fd2); close(fd2);

View File

@ -204,6 +204,7 @@ int DNSResolver::handle_event(int rfd, int wfd) {
default: default:
// Unreachable // Unreachable
assert(0); assert(0);
abort();
} }
} }

View File

@ -250,6 +250,7 @@ int DNSTracker::resolve(Address *result, DNSQuery *dnsq) {
return DNS_STATUS_OK; return DNS_STATUS_OK;
default: default:
assert(0); assert(0);
abort();
} }
} }

View File

@ -158,6 +158,8 @@ Downstream *DownstreamQueue::remove_and_get_blocked(Downstream *downstream,
auto next_downstream = link->downstream; auto next_downstream = link->downstream;
auto link2 = next_downstream->detach_blocked_link(); auto link2 = next_downstream->detach_blocked_link();
// This is required with --disable-assert.
(void)link2;
assert(link2 == link); assert(link2 == link);
ent.blocked.remove(link); ent.blocked.remove(link);
delete link; delete link;

View File

@ -334,6 +334,7 @@ int Http2Session::resolve_name() {
return 0; return 0;
default: default:
assert(0); assert(0);
abort();
} }
} }
@ -2115,7 +2116,10 @@ int Http2Session::write_tls() {
for (;;) { for (;;) {
if (wb_.rleft() > 0) { if (wb_.rleft() > 0) {
auto iovcnt = wb_.riovec(&iov, 1); 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); auto nwrite = conn_.write_tls(iov.iov_base, iov.iov_len);
if (nwrite == 0) { if (nwrite == 0) {

View File

@ -1307,7 +1307,10 @@ int HttpDownstreamConnection::write_tls() {
while (input->rleft() > 0) { while (input->rleft() > 0) {
auto iovcnt = input->riovec(&iov, 1); 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); auto nwrite = conn_.write_tls(iov.iov_base, iov.iov_len);
if (nwrite == 0) { if (nwrite == 0) {

View File

@ -478,7 +478,10 @@ int LiveCheck::write_tls() {
for (;;) { for (;;) {
if (wb_.rleft() > 0) { if (wb_.rleft() > 0) {
auto iovcnt = wb_.riovec(&iov, 1); 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); auto nwrite = conn_.write_tls(iov.iov_base, iov.iov_len);
if (nwrite == 0) { if (nwrite == 0) {
@ -544,7 +547,10 @@ int LiveCheck::write_clear() {
for (;;) { for (;;) {
if (wb_.rleft() > 0) { if (wb_.rleft() > 0) {
auto iovcnt = wb_.riovec(&iov, 1); 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); auto nwrite = conn_.write_clear(iov.iov_base, iov.iov_len);
if (nwrite == 0) { if (nwrite == 0) {