diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea1bf4485b..b05e6d59fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: analysis: strategy: matrix: - tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, misra, modules, rpm, tcc, tokstyle] + tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, misra, modules, rpm, slimcc, tcc, tokstyle] runs-on: ubuntu-latest steps: - name: Set up Docker Buildx diff --git a/other/docker/slimcc/.gitignore b/other/docker/slimcc/.gitignore new file mode 100644 index 0000000000..2526423199 --- /dev/null +++ b/other/docker/slimcc/.gitignore @@ -0,0 +1 @@ +!/Makefile diff --git a/other/docker/slimcc/Makefile b/other/docker/slimcc/Makefile new file mode 100644 index 0000000000..f97d089619 --- /dev/null +++ b/other/docker/slimcc/Makefile @@ -0,0 +1,13 @@ +SOURCES := auto_tests/send_message_test.c \ + auto_tests/auto_test_support.c \ + testing/misc_tools.c \ + $(wildcard tox*/*.c tox*/*/*.c) \ + third_party/cmp/cmp.c +OBJECTS := $(SOURCES:.c=.o) + +CC := /work/slimcc/slimcc +CFLAGS := $(shell pkg-config --cflags libsodium opus vpx) +LDFLAGS := $(shell pkg-config --libs libsodium opus vpx) + +send_message_test: $(OBJECTS) + $(CC) -o $@ $+ $(LDFLAGS) diff --git a/other/docker/slimcc/run b/other/docker/slimcc/run new file mode 100755 index 0000000000..82d7112041 --- /dev/null +++ b/other/docker/slimcc/run @@ -0,0 +1,6 @@ +#!/bin/sh + +set -eux +BUILD=slimcc +other/docker/sources/build +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" . diff --git a/other/docker/slimcc/slimcc.Dockerfile b/other/docker/slimcc/slimcc.Dockerfile new file mode 100644 index 0000000000..8cfcde002a --- /dev/null +++ b/other/docker/slimcc/slimcc.Dockerfile @@ -0,0 +1,28 @@ +FROM toxchat/c-toxcore:sources AS sources +FROM ubuntu:22.04 + +RUN apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ + ca-certificates \ + gcc \ + git \ + libc-dev \ + libopus-dev \ + libsodium-dev \ + libvpx-dev \ + make \ + pkg-config \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /work/slimcc +RUN ["git", "clone", "--depth=1", "https://github.com/fuhsnn/slimcc", "/work/slimcc"] +RUN ["make", "CFLAGS=-O3"] + +WORKDIR /work/c-toxcore +COPY --from=sources /src/ /work/c-toxcore +COPY other/docker/slimcc/Makefile /work/c-toxcore/ +RUN ["make"] + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN ./send_message_test | grep "tox clients connected" diff --git a/toxcore/network.c b/toxcore/network.c index 69d44d7a2c..05b1400a5a 100644 --- a/toxcore/network.c +++ b/toxcore/network.c @@ -335,8 +335,6 @@ static void fill_addr6(const IP6 *ip, struct in6_addr *addr) #define INADDR_LOOPBACK 0x7f000001 #endif /* !defined(INADDR_LOOPBACK) */ -static const IP empty_ip = {{0}}; - IP4 get_ip4_broadcast(void) { const IP4 ip4_broadcast = { INADDR_BROADCAST }; @@ -361,7 +359,7 @@ IP4 get_ip4_loopback(void) IP6 get_ip6_loopback(void) { /* in6addr_loopback isn't available everywhere, so we do it ourselves. */ - IP6 loopback = empty_ip.ip.v6; + IP6 loopback = {{0}}; loopback.uint8[15] = 1; return loopback; } @@ -1492,6 +1490,8 @@ int ipport_cmp_handler(const void *a, const void *b, size_t size) return cmp_uint(ipp_a->port, ipp_b->port); } +static const IP empty_ip = {{0}}; + /** nulls out ip */ void ip_reset(IP *ip) { @@ -1502,6 +1502,8 @@ void ip_reset(IP *ip) *ip = empty_ip; } +static const IP_Port empty_ip_port = {{{0}}}; + /** nulls out ip_port */ void ipport_reset(IP_Port *ipport) { @@ -1509,7 +1511,6 @@ void ipport_reset(IP_Port *ipport) return; } - const IP_Port empty_ip_port = {{{0}}}; *ipport = empty_ip_port; } @@ -1520,7 +1521,7 @@ void ip_init(IP *ip, bool ipv6enabled) return; } - *ip = empty_ip; + ip_reset(ip); ip->family = ipv6enabled ? net_family_ipv6() : net_family_ipv4(); }