diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a6110961..80c499c8 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -52,6 +52,24 @@ jobs: test/health.awk < log > json scp -o "StrictHostKeyChecking=no" json "root@176.9.217.245:/data/downloads/health/linux_${{ matrix.target }}_${{ matrix.cc }}_${{ matrix.ssl }}_${{ matrix.select }}_$(date +"%Y%m%d").json" + c89: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: [diabish, ppc_diabish] + ssl: ["", BUILTIN] + name: C89 ${{ matrix.target }} SSL=${{ matrix.ssl }} + env: + SSL: ${{ matrix.ssl }} + TFLAGS: -DMG_ENABLE_POLL=0 -DMG_ENABLE_EPOLL=0 -DMG_ENABLE_CHACHA20=0 -DMQTT_LOCALHOST -DNO_ZU_TEST + steps: + - uses: actions/checkout@v5 + with: { fetch-depth: 2 } + - run: | # GH runners seem to overflow the 32-bit FS for the QEMU PPC (works for me in RHEL9) + if [[ "${{ matrix.target }}" = ppc_* ]]; then export TFLAGS="$TFLAGS -D_FILE_OFFSET_BITS=64"; fi + sudo apt -y update ; sudo apt -y install binfmt-support qemu-user-static && ./test/setup_mqtt_server.sh && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test ${{ matrix.target }} + mip: runs-on: ubuntu-latest strategy: @@ -87,13 +105,13 @@ jobs: strategy: fail-fast: false matrix: - target: [mip_vc98] + target: [mip_vc98, mip_diabish, mip_ppc_diabish] ipv6: [0, 1] name: MIP C89 ${{ matrix.target }} IPV6=${{ matrix.ipv6 }} steps: - uses: actions/checkout@v5 with: { fetch-depth: 2 } - - run: make -C test ${{ matrix.target }} IPV6=${{ matrix.ipv6 }} + - run: sudo apt -y update ; sudo apt -y install binfmt-support qemu-user-static && docker run --rm --privileged multiarch/qemu-user-static --reset -p yes && make -C test ${{ matrix.target }} IPV6=${{ matrix.ipv6 }} mipbe: runs-on: ubuntu-latest strategy: diff --git a/mongoose.c b/mongoose.c index 50a27d18..a3f44d52 100644 --- a/mongoose.c +++ b/mongoose.c @@ -1014,9 +1014,11 @@ static size_t mg_dash_print_endpoint(mg_pfn_t fn, void *arg, va_list *ap) { void mg_dash_send_change(struct mg_mgr *mgr, struct mg_field_set *set) { struct mg_connection *c; for (c = mgr->conns; c != NULL; c = c->next) { - struct mg_dash_cdata *d = (struct mg_dash_cdata *) c->data; - struct mg_dash_user *u = d->u; + struct mg_dash_cdata *d; + struct mg_dash_user *u; if (!c->is_websocket) continue; + d = (struct mg_dash_cdata *) c->data; + u = d->u; if (u == NULL) continue; if (set->index != NULL && *set->index < 0) { int sz = mg_dash_array_size(set, u); @@ -8797,7 +8799,7 @@ static void rx_ndp_ra(struct mg_tcpip_if *ifp, struct pkt *pkt) { bool gotl2addr = false, gotprefix = false, changed = false; uint8_t l2[sizeof(struct mg_l2addr)]; uint32_t mtu = 0; - uint8_t *prefix, prefix_len; + uint8_t *prefix = NULL, prefix_len = 0; if (pkt->pay.len < sizeof(*ra)) return; if (ifp->state6 == MG_TCPIP_STATE_UP) { @@ -18841,7 +18843,7 @@ void mg_tls_ctx_free(struct mg_mgr *mgr) { -#if MG_TLS == MG_TLS_BUILTIN +#if MG_TLS == MG_TLS_BUILTIN && MG_ENABLE_CHACHA20 // ******* BEGIN: chacha-portable/chacha-portable.h ******** #if !defined(__cplusplus) && !defined(_MSC_VER) && \ diff --git a/mongoose.h b/mongoose.h index 077cdab9..3855e371 100644 --- a/mongoose.h +++ b/mongoose.h @@ -3363,7 +3363,7 @@ int mg_uecc_generate_random_int(mg_uecc_word_t *random, -#if MG_TLS == MG_TLS_BUILTIN +#if MG_TLS == MG_TLS_BUILTIN && MG_ENABLE_CHACHA20 #ifndef __PORTABLE_8439_H #define __PORTABLE_8439_H #if defined(__cplusplus) diff --git a/src/dash.c b/src/dash.c index 25e5a647..8e47ea29 100644 --- a/src/dash.c +++ b/src/dash.c @@ -167,9 +167,11 @@ static size_t mg_dash_print_endpoint(mg_pfn_t fn, void *arg, va_list *ap) { void mg_dash_send_change(struct mg_mgr *mgr, struct mg_field_set *set) { struct mg_connection *c; for (c = mgr->conns; c != NULL; c = c->next) { - struct mg_dash_cdata *d = (struct mg_dash_cdata *) c->data; - struct mg_dash_user *u = d->u; + struct mg_dash_cdata *d; + struct mg_dash_user *u; if (!c->is_websocket) continue; + d = (struct mg_dash_cdata *) c->data; + u = d->u; if (u == NULL) continue; if (set->index != NULL && *set->index < 0) { int sz = mg_dash_array_size(set, u); diff --git a/src/net_builtin.c b/src/net_builtin.c index 24c3acf1..bca3fbd4 100644 --- a/src/net_builtin.c +++ b/src/net_builtin.c @@ -972,7 +972,7 @@ static void rx_ndp_ra(struct mg_tcpip_if *ifp, struct pkt *pkt) { bool gotl2addr = false, gotprefix = false, changed = false; uint8_t l2[sizeof(struct mg_l2addr)]; uint32_t mtu = 0; - uint8_t *prefix, prefix_len; + uint8_t *prefix = NULL, prefix_len = 0; if (pkt->pay.len < sizeof(*ra)) return; if (ifp->state6 == MG_TCPIP_STATE_UP) { diff --git a/src/tls_chacha20.c b/src/tls_chacha20.c index bf03d01e..c69516fe 100644 --- a/src/tls_chacha20.c +++ b/src/tls_chacha20.c @@ -7,7 +7,7 @@ #include "tls_chacha20.h" #include "tls.h" -#if MG_TLS == MG_TLS_BUILTIN +#if MG_TLS == MG_TLS_BUILTIN && MG_ENABLE_CHACHA20 // ******* BEGIN: chacha-portable/chacha-portable.h ******** #if !defined(__cplusplus) && !defined(_MSC_VER) && \ diff --git a/src/tls_chacha20.h b/src/tls_chacha20.h index 733d0404..2571d0d2 100644 --- a/src/tls_chacha20.h +++ b/src/tls_chacha20.h @@ -8,7 +8,7 @@ #include "config.h" #include "tls.h" -#if MG_TLS == MG_TLS_BUILTIN +#if MG_TLS == MG_TLS_BUILTIN && MG_ENABLE_CHACHA20 #ifndef __PORTABLE_8439_H #define __PORTABLE_8439_H #if defined(__cplusplus) diff --git a/test/Makefile b/test/Makefile index e9f0f136..5d4aa0f5 100644 --- a/test/Makefile +++ b/test/Makefile @@ -248,6 +248,26 @@ mip_port_s390: CC = $(DOCKER) mdashnet/s390 cc mip_port_s390: RUN = $(DOCKER) --init mdashnet/s390 mip_port_s390: mip_port_test +diabish: CC = gcc +diabish: CFLAGS += -std=gnu89 -Werror=declaration-after-statement -Werror=vla -Wno-pedantic +diabish: test + +mip_diabish: CC = gcc +mip_diabish: CFLAGS += -std=gnu89 -Werror=declaration-after-statement -Werror=vla -Wno-pedantic +mip_diabish: mip_test + +ppc_diabish: ASAN= +ppc_diabish: CFLAGS += -std=gnu89 -Werror=declaration-after-statement -Werror=vla -Wno-pedantic +ppc_diabish: CC = $(DOCKER) dockcross/linux-ppc powerpc-unknown-linux-gnu-gcc -static +ppc_diabish: RUN = qemu-ppc-static +ppc_diabish: test + +mip_ppc_diabish: ASAN= +mip_ppc_diabish: CFLAGS += -std=gnu89 -Werror=declaration-after-statement -Werror=vla -Wno-pedantic +mip_ppc_diabish: CC = $(DOCKER) dockcross/linux-ppc powerpc-unknown-linux-gnu-gcc -static +mip_ppc_diabish: RUN = qemu-ppc-static +mip_ppc_diabish: mip_test + arm: DEFS += -DMG_ENABLE_POSIX_FS=0 -DMG_ENABLE_TCPIP=1 -DMG_ENABLE_TCPIP_DRIVER_INIT=0 -DMG_ARCH=MG_ARCH_ARMGCC -DNO_SLEEP_ABORT arm: mongoose.h $(SRCS) mip_test.c $(DOCKER) mdashnet/armgcc arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb $(SRCS) $(OPTS) $(WARN) $(INCS) $(DEFS) $(TFLAGS) -o unit_test -nostartfiles --specs nosys.specs -e 0 diff --git a/test/unit_test.c b/test/unit_test.c index b632ec83..e08c75a6 100644 --- a/test/unit_test.c +++ b/test/unit_test.c @@ -339,7 +339,7 @@ static void sntp_cb(struct mg_connection *c, int ev, void *ev_data) { int64_t received = *(int64_t *) ev_data; *(int64_t *) c->fn_data = received; MG_DEBUG(("got time: %lld", received)); -#if MG_ARCH == MG_ARCH_UNIX +#if MG_ARCH == MG_ARCH_UNIX && defined(__STDC__) && defined(__STDC_VERSION__) struct timeval tv = {0, 0}; gettimeofday(&tv, 0); int64_t ms = (int64_t) tv.tv_sec * 1000 + tv.tv_usec / 1000; @@ -1462,7 +1462,7 @@ static void test_tls(void) { const char *url = "https://localhost:12347"; char buf[FETCH_BUF_SIZE]; struct mg_tls_opts opts; - struct mg_str data = mg_unpacked("/Makefile"); + struct mg_str data = mg_unpacked("/fuzz.c"); char bigdata[FETCH_BUF_SIZE - 256]; // leave extra room struct mg_str bd; ASSERT(data.buf != NULL && data.len > 0); @@ -1505,6 +1505,7 @@ static void test_tls(void) { // otherwise it will end with 200 and shorter file contents ASSERT(fetch(&mgr, buf, "https://localhost:8443", "GET /thefile HTTP/1.0\n\n") == 200); + data = mg_unpacked("/Makefile"); ASSERT(cmpbody(buf, data.buf) == 0); // "thefile" links to Makefile ASSERT(system("killall tls_multirec/server") == 0); } else { @@ -3014,7 +3015,7 @@ static void test_util(void) { static void test_crc32(void) { // echo -n aaa | cksum -o3 ASSERT(mg_crc32(0, 0, 0) == 0); - ASSERT(mg_crc32(0, "a", 1) == 3904355907); + ASSERT(mg_crc32(0, "a", 1) == 3904355907U); ASSERT(mg_crc32(0, "abc", 3) == 891568578); ASSERT(mg_crc32(mg_crc32(0, "ab", 2), "c", 1) == 891568578); } @@ -4501,7 +4502,7 @@ static bool test_upload_dir(const struct mg_dash_user *u, char *buf, size_t len) struct test_file_entry { char name[64]; - size_t size; + uint64_t size; }; static struct test_file_entry s_test_file; static int s_test_file_index;