diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01858f2f..d150e609 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,24 +1,6 @@ name: build on: [push, pull_request] jobs: - linux-capture: - runs-on: ubuntu-latest - name: linux capture - steps: - - uses: actions/checkout@v3 - - name: Start tcpdump - run: | - sudo tcpdump -nn -i any port 123 or port 53 -w sntp.cap & - sleep 1 - - name: test - run: make clean test IPV6=0 SSL= OPTS= V=4 TFLAGS=-DMG_ENABLE_POLL=1 - - name: Upload capture - if: always() - run: | - sleep 1 - sudo kill -2 $(pgrep tcpdump) - sleep 1 - sudo curl -F "file=@sntp.cap" https://file.io/?expires=1w linux: runs-on: ubuntu-latest strategy: @@ -55,7 +37,7 @@ jobs: - name: Install packages run: HOMEBREW_NO_AUTO_UPDATE=1 brew install jq mbedtls openssl - name: make - run: make test++ upload-coverage IPV6=0 ASAN_OPTIONS= + run: make test++ upload-coverage IPV6=0 ASAN_OPTIONS= TFLAGS=-DMG_ENABLE_POLL=1 - name: openssl run: make test SSL=OPENSSL IPV6=0 ASAN_OPTIONS= OPENSSL=`echo /usr/local/Cellar/openssl*/*` - name: exports diff --git a/Makefile b/Makefile index 61c48ff7..ecfccaee 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ mg_prefix: mongoose.c mongoose.h # C++ build test++: CC = g++ -test++: C_WARN = -std=c++2a -Wno-shadow -Wno-missing-field-initializers -Wno-deprecated +test++: C_WARN = -std=c++2a -Wno-vla -Wno-shadow -Wno-missing-field-initializers -Wno-deprecated test++: test musl: test diff --git a/mongoose.c b/mongoose.c index a4a7b304..967e8254 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3875,7 +3875,6 @@ int64_t mg_sntp_parse(const unsigned char *buf, size_t len) { } else { MG_ERROR(("unexpected version: %d", version)); } - if (res == -1) mg_hexdump(buf, len); return res; } @@ -4415,9 +4414,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) { } } - int res = poll(fds, n, ms); - MG_DEBUG(("n=%d ms=%d res=%d errno=%d", n, ms, res, errno)); - if (res < 0) { + if (poll(fds, n, ms) < 0) { MG_ERROR(("poll failed, errno: %d", MG_SOCK_ERRNO)); } else { n = 0; @@ -4428,8 +4425,6 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) { c->is_readable = (unsigned) (fds[n].revents & POLLIN ? 1 : 0); c->is_writable = (unsigned) (fds[n].revents & POLLOUT ? 1 : 0); if (mg_tls_pending(c) > 0) c->is_readable = 1; - MG_DEBUG((" fd=%d events=%d revents=%d", fds[n].fd, fds[n].events, - fds[n].revents)); fds[n].revents = 0; n++; } diff --git a/src/sntp.c b/src/sntp.c index e0c801b5..f46682e8 100644 --- a/src/sntp.c +++ b/src/sntp.c @@ -25,7 +25,6 @@ int64_t mg_sntp_parse(const unsigned char *buf, size_t len) { } else { MG_ERROR(("unexpected version: %d", version)); } - if (res == -1) mg_hexdump(buf, len); return res; } diff --git a/src/sock.c b/src/sock.c index b71e0841..f3ba793d 100644 --- a/src/sock.c +++ b/src/sock.c @@ -496,9 +496,7 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) { } } - int res = poll(fds, n, ms); - MG_DEBUG(("n=%d ms=%d res=%d errno=%d", n, ms, res, errno)); - if (res < 0) { + if (poll(fds, n, ms) < 0) { MG_ERROR(("poll failed, errno: %d", MG_SOCK_ERRNO)); } else { n = 0; @@ -509,8 +507,6 @@ static void mg_iotest(struct mg_mgr *mgr, int ms) { c->is_readable = (unsigned) (fds[n].revents & POLLIN ? 1 : 0); c->is_writable = (unsigned) (fds[n].revents & POLLOUT ? 1 : 0); if (mg_tls_pending(c) > 0) c->is_readable = 1; - MG_DEBUG((" fd=%d events=%d revents=%d", fds[n].fd, fds[n].events, - fds[n].revents)); fds[n].revents = 0; n++; } diff --git a/test/unit_test.c b/test/unit_test.c index 54867eef..00dd1798 100644 --- a/test/unit_test.c +++ b/test/unit_test.c @@ -296,12 +296,13 @@ static void test_sntp_server(const char *url) { int64_t ms = 0; struct mg_mgr mgr; struct mg_connection *c = NULL; + int i; mg_mgr_init(&mgr); c = mg_sntp_connect(&mgr, url, sntp_cb, &ms); ASSERT(c != NULL); ASSERT(c->is_udp == 1); - for (int i = 0; i < 60 && ms == 0; i++) mg_mgr_poll(&mgr, 50); + for (i = 0; i < 60 && ms == 0; i++) mg_mgr_poll(&mgr, 50); MG_DEBUG(("server: %s, ms: %lld", url ? url : "(default)", ms)); ASSERT(ms > 0); mg_mgr_free(&mgr);