From 511bfe39c8e801cfa48071f9f481b05f3e52435d Mon Sep 17 00:00:00 2001 From: iphydf Date: Tue, 30 Jan 2024 12:40:30 +0000 Subject: [PATCH] cleanup: Use Bazel modules to enforce proper `#include` hygiene. --- .clang-tidy | 2 - .github/workflows/ci.yml | 2 +- other/analysis/run-clang-tidy | 8 +- .../docker/tox-bootstrapd.sha256 | 2 +- other/bootstrap_daemon/src/log.h | 2 +- .../bootstrap_daemon/src/log_backend_stdout.h | 7 +- .../bootstrap_daemon/src/log_backend_syslog.h | 7 +- other/docker/modules/check | 93 +++++++++++++++++++ other/docker/modules/modules.Dockerfile | 20 ++++ other/docker/modules/run | 6 ++ other/event_tooling/generate_event_c.cpp | 1 + toxcore/BUILD.bazel | 64 +++++++++++++ toxcore/DHT.c | 1 + toxcore/DHT_test_util.cc | 3 + toxcore/DHT_test_util.hh | 1 + toxcore/LAN_discovery.c | 1 + toxcore/LAN_discovery.h | 1 + toxcore/Messenger.c | 1 + toxcore/Messenger.h | 10 ++ toxcore/TCP_client.c | 1 + toxcore/TCP_client.h | 3 + toxcore/TCP_common.c | 1 + toxcore/TCP_common.h | 2 + toxcore/TCP_connection.c | 1 + toxcore/TCP_connection.h | 8 ++ toxcore/TCP_server.c | 1 + toxcore/TCP_server.h | 5 + toxcore/announce.c | 1 + toxcore/announce.h | 7 ++ toxcore/bin_pack.c | 1 + toxcore/bin_unpack.c | 1 + toxcore/ccompat.h | 6 -- toxcore/crypto_core.c | 1 + toxcore/crypto_core_test_util.cc | 3 + toxcore/events/conference_connected.c | 1 + toxcore/events/conference_invite.c | 1 + toxcore/events/conference_message.c | 1 + toxcore/events/conference_peer_list_changed.c | 1 + toxcore/events/conference_peer_name.c | 1 + toxcore/events/conference_title.c | 1 + toxcore/events/dht_get_nodes_response.c | 3 +- toxcore/events/events_alloc.h | 4 + toxcore/events/file_chunk_request.c | 1 + toxcore/events/file_recv.c | 1 + toxcore/events/file_recv_chunk.c | 1 + toxcore/events/file_recv_control.c | 1 + toxcore/events/friend_connection_status.c | 1 + toxcore/events/friend_lossless_packet.c | 1 + toxcore/events/friend_lossy_packet.c | 1 + toxcore/events/friend_message.c | 1 + toxcore/events/friend_name.c | 1 + toxcore/events/friend_read_receipt.c | 1 + toxcore/events/friend_request.c | 3 +- toxcore/events/friend_status.c | 1 + toxcore/events/friend_status_message.c | 1 + toxcore/events/friend_typing.c | 1 + toxcore/events/group_custom_packet.c | 1 + toxcore/events/group_custom_private_packet.c | 1 + toxcore/events/group_invite.c | 1 + toxcore/events/group_join_fail.c | 1 + toxcore/events/group_message.c | 1 + toxcore/events/group_moderation.c | 1 + toxcore/events/group_password.c | 1 + toxcore/events/group_peer_exit.c | 1 + toxcore/events/group_peer_join.c | 1 + toxcore/events/group_peer_limit.c | 1 + toxcore/events/group_peer_name.c | 1 + toxcore/events/group_peer_status.c | 1 + toxcore/events/group_privacy_state.c | 1 + toxcore/events/group_private_message.c | 1 + toxcore/events/group_self_join.c | 1 + toxcore/events/group_topic.c | 1 + toxcore/events/group_topic_lock.c | 1 + toxcore/events/group_voice_state.c | 1 + toxcore/events/self_connection_status.c | 1 + toxcore/forwarding.c | 1 + toxcore/forwarding.h | 4 + toxcore/friend_connection.c | 3 + toxcore/friend_connection.h | 6 ++ toxcore/friend_requests.c | 4 + toxcore/friend_requests.h | 3 + toxcore/group.c | 1 + toxcore/group.h | 7 ++ toxcore/group_announce.c | 2 + toxcore/group_announce.h | 6 ++ toxcore/group_chats.c | 1 + toxcore/group_chats.h | 3 + toxcore/group_common.h | 6 ++ toxcore/group_connection.c | 1 + toxcore/group_connection.h | 7 ++ toxcore/group_moderation.c | 1 + toxcore/group_moderation.h | 3 + toxcore/group_onion_announce.c | 3 + toxcore/group_onion_announce.h | 2 + toxcore/group_pack.c | 3 + toxcore/group_pack.h | 1 + toxcore/list.c | 1 + toxcore/logger.c | 1 + toxcore/mem.c | 1 + toxcore/mem_test_util.cc | 3 + toxcore/mono_time.c | 1 + toxcore/net_crypto.c | 1 + toxcore/net_crypto.h | 6 ++ toxcore/network.c | 1 + toxcore/network.h | 1 + toxcore/network_test_util.cc | 4 + toxcore/onion.c | 1 + toxcore/onion.h | 4 + toxcore/onion_announce.c | 1 + toxcore/onion_announce.h | 6 ++ toxcore/onion_client.c | 3 + toxcore/onion_client.h | 7 ++ toxcore/ping.c | 1 + toxcore/ping.h | 4 + toxcore/ping_array.c | 1 + toxcore/ping_array.h | 1 + toxcore/shared_key_cache.c | 1 + toxcore/shared_key_cache.h | 1 + toxcore/state.h | 1 + toxcore/timed_auth.c | 1 + toxcore/timed_auth.h | 1 + toxcore/tox.c | 1 + toxcore/tox_dispatch.c | 1 + toxcore/tox_dispatch.h | 1 + toxcore/tox_event.c | 1 + toxcore/tox_events.c | 1 + toxcore/tox_struct.h | 3 + toxcore/tox_unpack.c | 1 + 128 files changed, 432 insertions(+), 21 deletions(-) create mode 100755 other/docker/modules/check create mode 100644 other/docker/modules/modules.Dockerfile create mode 100755 other/docker/modules/run diff --git a/.clang-tidy b/.clang-tidy index f1aca9f9fa..ad1a47c263 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -41,7 +41,5 @@ CheckOptions: value: true - key: concurrency-mt-unsafe.FunctionSet value: posix - - key: misc-include-cleaner.IgnoreHeaders - value: "pthread.h;stdbool.h;stddef.h;stdint.;stdint.h;stdint...;cstdint;sodium.*;sys/.*;unistd.h;opus.*;vpx.*;attributes.h;tox_struct.h" - key: readability-function-cognitive-complexity.Threshold value: 153 # TODO(iphydf): Decrease. tox_new is the highest at the moment. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4c17188c9..ea1bf4485b 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, rpm, tcc, tokstyle] + tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, goblint, infer, misra, modules, rpm, tcc, tokstyle] runs-on: ubuntu-latest steps: - name: Set up Docker Buildx diff --git a/other/analysis/run-clang-tidy b/other/analysis/run-clang-tidy index dc07f94651..8caed6a754 100755 --- a/other/analysis/run-clang-tidy +++ b/other/analysis/run-clang-tidy @@ -139,6 +139,10 @@ CHECKS="$CHECKS,-cert-dcl03-c" CHECKS="$CHECKS,-hicpp-static-assert" CHECKS="$CHECKS,-misc-static-assert" +# Doesn't consider use of preprocessor macros as needing a header, breaking +# struct definitions that depend on size macros from e.g. crypto_core.h. +CHECKS="$CHECKS,-misc-include-cleaner" + set -eux # TODO(iphydf): Add toxav. @@ -154,7 +158,7 @@ copy_files() { find "${DIRS[@]}" \ -maxdepth 1 -type d -exec mkdir -p "$1/{}" \; find "${DIRS[@]}" \ - -maxdepth 1 -name "*.c" -exec cp "{}" "$1/{}" \; + -maxdepth 1 -name "*.[ch]" -exec cp "{}" "$1/{}" \; } run() { @@ -166,7 +170,7 @@ run() { ls .clang-tidy copy_files a if ! find "${DIRS[@]}" \ - -maxdepth 1 -name "*.c" -print0 \ + -maxdepth 1 -name "*.[ch]" -print0 \ | xargs -0 -n15 -P"$(nproc)" clang-tidy \ -p="$PWD/_build" \ --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \ diff --git a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 index 93e250056d..faef8b8690 100644 --- a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 +++ b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 @@ -1 +1 @@ -e9e6e7baafe3cfe9b212ffb4f1ea8a8b48e2dc1ee4c07c6b1b0b04893b3b6464 /usr/local/bin/tox-bootstrapd +af58a125e5c80d7a19bc7f32868c1edfdf80f366e3bf778728961a50ce63ee26 /usr/local/bin/tox-bootstrapd diff --git a/other/bootstrap_daemon/src/log.h b/other/bootstrap_daemon/src/log.h index 162b868396..4e80fd5774 100644 --- a/other/bootstrap_daemon/src/log.h +++ b/other/bootstrap_daemon/src/log.h @@ -12,7 +12,7 @@ #include -#include "../../../toxcore/ccompat.h" +#include "../../../toxcore/attributes.h" typedef enum LOG_BACKEND { LOG_BACKEND_STDOUT, diff --git a/other/bootstrap_daemon/src/log_backend_stdout.h b/other/bootstrap_daemon/src/log_backend_stdout.h index b2c8dc7bbd..131d48da05 100644 --- a/other/bootstrap_daemon/src/log_backend_stdout.h +++ b/other/bootstrap_daemon/src/log_backend_stdout.h @@ -10,10 +10,11 @@ #ifndef C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_STDOUT_H #define C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_STDOUT_H -#include "log.h" - #include +#include "../../../toxcore/attributes.h" +#include "log.h" + void log_backend_stdout_write(LOG_LEVEL level, const char *format, va_list args) GNU_PRINTF(2, 0); -#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_STDOUT_H +#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_STDOUT_H diff --git a/other/bootstrap_daemon/src/log_backend_syslog.h b/other/bootstrap_daemon/src/log_backend_syslog.h index 6cb9eade26..8e919f03af 100644 --- a/other/bootstrap_daemon/src/log_backend_syslog.h +++ b/other/bootstrap_daemon/src/log_backend_syslog.h @@ -10,12 +10,13 @@ #ifndef C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_SYSLOG_H #define C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_SYSLOG_H -#include "log.h" - #include +#include "../../../toxcore/attributes.h" +#include "log.h" + void log_backend_syslog_open(void); void log_backend_syslog_close(void); void log_backend_syslog_write(LOG_LEVEL level, const char *format, va_list args) GNU_PRINTF(2, 0); -#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_SYSLOG_H +#endif // C_TOXCORE_OTHER_BOOTSTRAP_DAEMON_SRC_LOG_BACKEND_SYSLOG_H diff --git a/other/docker/modules/check b/other/docker/modules/check new file mode 100755 index 0000000000..46473f3ba5 --- /dev/null +++ b/other/docker/modules/check @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +import glob as py_glob +import os +import subprocess +import sys +from typing import Optional + +LIBS = {} + + +def load(bzl: str, *syms: str) -> None: + pass + + +def exports_files(srcs: list[str], + visibility: Optional[list[str]] = None) -> None: + pass + + +def cc_library(name: str, **kwargs: list[str]) -> None: + LIBS[name] = kwargs + + +def cc_test(name: str, **kwargs: list[str]) -> None: + pass + + +def cc_fuzz_test(name: str, **kwargs: list[str]) -> None: + pass + + +def select(selector: dict[str, list[str]]) -> list[str]: + return selector["//tools/config:linux"] + + +def glob(include: list[str]) -> list[str]: + return [ + f[len("toxcore/"):] for p in include + for f in py_glob.glob(os.path.join("toxcore", p)) + ] + + +def alias(name: str, actual: str, visibility: list[str]) -> None: + pass + + +def sh_library(name: str, **kwargs: list[str]) -> None: + pass + + +def main() -> None: + with open("toxcore/BUILD.bazel", "r") as fh: + exec(fh.read()) + + with open("module.modulemap", "w") as fh: + for name, lib in LIBS.items(): + fh.write("module " + name + " {\n") + for hdr in lib["hdrs"]: + fh.write(f' header "toxcore/{hdr}"\n') + for dep in lib.get("deps", []): + if dep[0] == ":": + fh.write(f" use {dep[1:]}\n") + fh.write("}\n") + + srcs = sorted( + set( + os.path.join("toxcore", src) for lib in LIBS.values() + for src in lib.get("srcs", []))) + for src in srcs: + print(f"Validating {src}", file=sys.stderr) + subprocess.run( + [ + "clang", + "-xc++", + "-fsyntax-only", + "-Wall", + "-Werror", + "-Wno-missing-braces", + "-std=c++23", + "-fdiagnostics-color=always", + "-fmodules", + # TODO(iphydf): Fix all the other errors. + # "-fmodules-strict-decluse", + "-fmodules-decluse", + "-fmodule-map-file=module.modulemap", + src, + ], + check=True, + ) + + +if __name__ == "__main__": + main() diff --git a/other/docker/modules/modules.Dockerfile b/other/docker/modules/modules.Dockerfile new file mode 100644 index 0000000000..225be26254 --- /dev/null +++ b/other/docker/modules/modules.Dockerfile @@ -0,0 +1,20 @@ +FROM toxchat/c-toxcore:sources AS sources +FROM alpine:3.19.0 + +RUN ["apk", "add", "--no-cache", \ + "bash", \ + "clang", \ + "libconfig-dev", \ + "libsodium-dev", \ + "libvpx-dev", \ + "linux-headers", \ + "opus-dev", \ + "pkgconfig", \ + "python3"] + +WORKDIR /work +COPY --from=sources /src/ /work/ + +COPY toxcore/BUILD.bazel /work/toxcore/ +COPY other/docker/modules/check /work/other/docker/modules/ +RUN ["other/docker/modules/check"] diff --git a/other/docker/modules/run b/other/docker/modules/run new file mode 100755 index 0000000000..cfe53a1eaa --- /dev/null +++ b/other/docker/modules/run @@ -0,0 +1,6 @@ +#!/bin/sh + +set -eux +BUILD=modules +other/docker/sources/build +docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/$BUILD.Dockerfile" . diff --git a/other/event_tooling/generate_event_c.cpp b/other/event_tooling/generate_event_c.cpp index bc7b2eb595..9ca15dd8a9 100644 --- a/other/event_tooling/generate_event_c.cpp +++ b/other/event_tooling/generate_event_c.cpp @@ -172,6 +172,7 @@ void generate_event_impl(const std::string& event_name, const std::vector #include "LAN_discovery.h" +#include "attributes.h" #include "bin_pack.h" #include "ccompat.h" #include "crypto_core.h" diff --git a/toxcore/DHT_test_util.cc b/toxcore/DHT_test_util.cc index 15e679f2f6..b87b585942 100644 --- a/toxcore/DHT_test_util.cc +++ b/toxcore/DHT_test_util.cc @@ -3,7 +3,10 @@ #include #include +#include "DHT.h" +#include "crypto_core.h" #include "crypto_core_test_util.hh" +#include "network.h" #include "network_test_util.hh" Node_format random_node_format(const Random *rng) diff --git a/toxcore/DHT_test_util.hh b/toxcore/DHT_test_util.hh index 5fa75b7f70..9c510c45ec 100644 --- a/toxcore/DHT_test_util.hh +++ b/toxcore/DHT_test_util.hh @@ -4,6 +4,7 @@ #include #include "DHT.h" +#include "crypto_core.h" #include "test_util.hh" template <> diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index 750759fd2d..e9e0acba13 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c @@ -38,6 +38,7 @@ #include #endif /* BSD */ +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "network.h" diff --git a/toxcore/LAN_discovery.h b/toxcore/LAN_discovery.h index 0c921fe9d1..94e5d3581c 100644 --- a/toxcore/LAN_discovery.h +++ b/toxcore/LAN_discovery.h @@ -9,6 +9,7 @@ #ifndef C_TOXCORE_TOXCORE_LAN_DISCOVERY_H #define C_TOXCORE_TOXCORE_LAN_DISCOVERY_H +#include "attributes.h" #include "network.h" /** diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 2655ae382e..275c68f226 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -18,6 +18,7 @@ #include "TCP_connection.h" #include "TCP_server.h" #include "announce.h" +#include "attributes.h" #include "bin_pack.h" #include "bin_unpack.h" #include "ccompat.h" diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 5b52dedccd..dceada215d 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -10,15 +10,25 @@ #ifndef C_TOXCORE_TOXCORE_MESSENGER_H #define C_TOXCORE_TOXCORE_MESSENGER_H +#include "DHT.h" +#include "TCP_client.h" #include "TCP_server.h" #include "announce.h" +#include "attributes.h" +#include "crypto_core.h" #include "forwarding.h" #include "friend_connection.h" #include "friend_requests.h" #include "group_announce.h" #include "group_common.h" #include "logger.h" +#include "mem.h" +#include "mono_time.h" #include "net_crypto.h" +#include "network.h" +#include "onion.h" +#include "onion_announce.h" +#include "onion_client.h" #include "state.h" #define MAX_NAME_LENGTH 128 diff --git a/toxcore/TCP_client.c b/toxcore/TCP_client.c index f65d4d60e0..b8047c8b7f 100644 --- a/toxcore/TCP_client.c +++ b/toxcore/TCP_client.c @@ -13,6 +13,7 @@ #include #include "TCP_common.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "forwarding.h" diff --git a/toxcore/TCP_client.h b/toxcore/TCP_client.h index 7210afd790..6be0c86e83 100644 --- a/toxcore/TCP_client.h +++ b/toxcore/TCP_client.h @@ -9,8 +9,11 @@ #ifndef C_TOXCORE_TOXCORE_TCP_CLIENT_H #define C_TOXCORE_TOXCORE_TCP_CLIENT_H +#include "attributes.h" #include "crypto_core.h" #include "forwarding.h" +#include "logger.h" +#include "mem.h" #include "mono_time.h" #include "network.h" diff --git a/toxcore/TCP_common.c b/toxcore/TCP_common.c index 56db6555c6..5842f60551 100644 --- a/toxcore/TCP_common.c +++ b/toxcore/TCP_common.c @@ -7,6 +7,7 @@ #include +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "logger.h" diff --git a/toxcore/TCP_common.h b/toxcore/TCP_common.h index c17e6c0bf8..4c50652687 100644 --- a/toxcore/TCP_common.h +++ b/toxcore/TCP_common.h @@ -6,7 +6,9 @@ #ifndef C_TOXCORE_TOXCORE_TCP_COMMON_H #define C_TOXCORE_TOXCORE_TCP_COMMON_H +#include "attributes.h" #include "crypto_core.h" +#include "logger.h" #include "mem.h" #include "network.h" diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c index 8e379442db..f2fc4e55f5 100644 --- a/toxcore/TCP_connection.c +++ b/toxcore/TCP_connection.c @@ -13,6 +13,7 @@ #include "DHT.h" #include "TCP_client.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "forwarding.h" diff --git a/toxcore/TCP_connection.h b/toxcore/TCP_connection.h index af93fb4252..d3211915fc 100644 --- a/toxcore/TCP_connection.h +++ b/toxcore/TCP_connection.h @@ -10,10 +10,18 @@ #define C_TOXCORE_TOXCORE_TCP_CONNECTION_H #include +#include #include "DHT.h" // for Node_format #include "TCP_client.h" #include "TCP_common.h" +#include "attributes.h" +#include "crypto_core.h" +#include "forwarding.h" +#include "logger.h" +#include "mem.h" +#include "mono_time.h" +#include "network.h" #define TCP_CONN_NONE 0 #define TCP_CONN_VALID 1 diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index de31fa1e5c..49ce8f7a24 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c @@ -19,6 +19,7 @@ #endif /* TCP_SERVER_USE_EPOLL */ #include "TCP_common.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "forwarding.h" diff --git a/toxcore/TCP_server.h b/toxcore/TCP_server.h index 3279b0168e..ff0bd05d05 100644 --- a/toxcore/TCP_server.h +++ b/toxcore/TCP_server.h @@ -9,8 +9,13 @@ #ifndef C_TOXCORE_TOXCORE_TCP_SERVER_H #define C_TOXCORE_TOXCORE_TCP_SERVER_H +#include "attributes.h" #include "crypto_core.h" #include "forwarding.h" +#include "logger.h" +#include "mem.h" +#include "mono_time.h" +#include "network.h" #include "onion.h" #define MAX_INCOMING_CONNECTIONS 256 diff --git a/toxcore/announce.c b/toxcore/announce.c index 8d5e112717..6b350d3f04 100644 --- a/toxcore/announce.c +++ b/toxcore/announce.c @@ -14,6 +14,7 @@ #include "DHT.h" #include "LAN_discovery.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "forwarding.h" diff --git a/toxcore/announce.h b/toxcore/announce.h index a47bd0df34..2c20c28b22 100644 --- a/toxcore/announce.h +++ b/toxcore/announce.h @@ -5,7 +5,14 @@ #ifndef C_TOXCORE_TOXCORE_ANNOUNCE_H #define C_TOXCORE_TOXCORE_ANNOUNCE_H +#include + +#include "attributes.h" +#include "crypto_core.h" #include "forwarding.h" +#include "logger.h" +#include "mem.h" +#include "mono_time.h" #define MAX_ANNOUNCEMENT_SIZE 512 diff --git a/toxcore/bin_pack.c b/toxcore/bin_pack.c index ca3f5caf9e..88ce074b6a 100644 --- a/toxcore/bin_pack.c +++ b/toxcore/bin_pack.c @@ -8,6 +8,7 @@ #include #include "../third_party/cmp/cmp.h" +#include "attributes.h" #include "ccompat.h" #include "logger.h" diff --git a/toxcore/bin_unpack.c b/toxcore/bin_unpack.c index 3784e0bc67..4397e39677 100644 --- a/toxcore/bin_unpack.c +++ b/toxcore/bin_unpack.c @@ -9,6 +9,7 @@ #include #include "../third_party/cmp/cmp.h" +#include "attributes.h" #include "ccompat.h" struct Bin_Unpack { diff --git a/toxcore/ccompat.h b/toxcore/ccompat.h index 4253dff06d..47ab9ed2bf 100644 --- a/toxcore/ccompat.h +++ b/toxcore/ccompat.h @@ -73,12 +73,6 @@ #endif /* !static_assert */ #endif /* !__cplusplus */ -#ifdef __GNUC__ -#define GNU_PRINTF(f, a) __attribute__((__format__(__printf__, f, a))) -#else -#define GNU_PRINTF(f, a) -#endif - //!TOKSTYLE+ #endif /* C_TOXCORE_TOXCORE_CCOMPAT_H */ diff --git a/toxcore/crypto_core.c b/toxcore/crypto_core.c index b82d300944..0323c8b2cd 100644 --- a/toxcore/crypto_core.c +++ b/toxcore/crypto_core.c @@ -16,6 +16,7 @@ #include +#include "attributes.h" #include "ccompat.h" #include "util.h" diff --git a/toxcore/crypto_core_test_util.cc b/toxcore/crypto_core_test_util.cc index 4d5f46c55f..b48871a538 100644 --- a/toxcore/crypto_core_test_util.cc +++ b/toxcore/crypto_core_test_util.cc @@ -3,6 +3,9 @@ #include #include +#include "crypto_core.h" +#include "test_util.hh" + Random_Funcs const Random_Class::vtable = { Method::invoke<&Random_Class::random_bytes>, Method::invoke<&Random_Class::random_uniform>, diff --git a/toxcore/events/conference_connected.c b/toxcore/events/conference_connected.c index 4fd5708a78..edd9a962a1 100644 --- a/toxcore/events/conference_connected.c +++ b/toxcore/events/conference_connected.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/conference_invite.c b/toxcore/events/conference_invite.c index f4ef1db4ee..fbdad0f756 100644 --- a/toxcore/events/conference_invite.c +++ b/toxcore/events/conference_invite.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/conference_message.c b/toxcore/events/conference_message.c index eb7064903a..806df134cb 100644 --- a/toxcore/events/conference_message.c +++ b/toxcore/events/conference_message.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/conference_peer_list_changed.c b/toxcore/events/conference_peer_list_changed.c index cff268ce30..e07f9a104e 100644 --- a/toxcore/events/conference_peer_list_changed.c +++ b/toxcore/events/conference_peer_list_changed.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/conference_peer_name.c b/toxcore/events/conference_peer_name.c index ce1b5bf828..de57aafb2e 100644 --- a/toxcore/events/conference_peer_name.c +++ b/toxcore/events/conference_peer_name.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/conference_title.c b/toxcore/events/conference_title.c index 7d52fda65b..aed5e46c40 100644 --- a/toxcore/events/conference_title.c +++ b/toxcore/events/conference_title.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/dht_get_nodes_response.c b/toxcore/events/dht_get_nodes_response.c index 80e450993e..11ab1c8389 100644 --- a/toxcore/events/dht_get_nodes_response.c +++ b/toxcore/events/dht_get_nodes_response.c @@ -7,6 +7,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" @@ -86,7 +87,7 @@ non_null() static void tox_event_dht_get_nodes_response_construct(Tox_Event_Dht_Get_Nodes_Response *dht_get_nodes_response) { *dht_get_nodes_response = (Tox_Event_Dht_Get_Nodes_Response) { - 0 + {0} }; } non_null() diff --git a/toxcore/events/events_alloc.h b/toxcore/events/events_alloc.h index b32c9aae06..a40db97052 100644 --- a/toxcore/events/events_alloc.h +++ b/toxcore/events/events_alloc.h @@ -8,7 +8,11 @@ #include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" +#include "../mem.h" +#include "../tox.h" #include "../tox_event.h" +#include "../tox_events.h" +#include "../tox_private.h" #ifdef __cplusplus extern "C" { diff --git a/toxcore/events/file_chunk_request.c b/toxcore/events/file_chunk_request.c index ec1da49bd3..1dd2126026 100644 --- a/toxcore/events/file_chunk_request.c +++ b/toxcore/events/file_chunk_request.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/file_recv.c b/toxcore/events/file_recv.c index b962980d7b..8d4315d25d 100644 --- a/toxcore/events/file_recv.c +++ b/toxcore/events/file_recv.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/file_recv_chunk.c b/toxcore/events/file_recv_chunk.c index 535f38bfcf..2e134e9c47 100644 --- a/toxcore/events/file_recv_chunk.c +++ b/toxcore/events/file_recv_chunk.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/file_recv_control.c b/toxcore/events/file_recv_control.c index a5a2373307..c46501f91f 100644 --- a/toxcore/events/file_recv_control.c +++ b/toxcore/events/file_recv_control.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/friend_connection_status.c b/toxcore/events/friend_connection_status.c index 81639b87e1..a8326ba8ed 100644 --- a/toxcore/events/friend_connection_status.c +++ b/toxcore/events/friend_connection_status.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/friend_lossless_packet.c b/toxcore/events/friend_lossless_packet.c index 0d752a0080..55f0bea380 100644 --- a/toxcore/events/friend_lossless_packet.c +++ b/toxcore/events/friend_lossless_packet.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/friend_lossy_packet.c b/toxcore/events/friend_lossy_packet.c index e667bf15b3..9d1d3edd6c 100644 --- a/toxcore/events/friend_lossy_packet.c +++ b/toxcore/events/friend_lossy_packet.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/friend_message.c b/toxcore/events/friend_message.c index 81173b3dab..b3a8f1ac5c 100644 --- a/toxcore/events/friend_message.c +++ b/toxcore/events/friend_message.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/friend_name.c b/toxcore/events/friend_name.c index 4cee44c2ee..266e5e696a 100644 --- a/toxcore/events/friend_name.c +++ b/toxcore/events/friend_name.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/friend_read_receipt.c b/toxcore/events/friend_read_receipt.c index 66f364ef1d..705d763115 100644 --- a/toxcore/events/friend_read_receipt.c +++ b/toxcore/events/friend_read_receipt.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/friend_request.c b/toxcore/events/friend_request.c index 3d7007126d..e54aadf6d5 100644 --- a/toxcore/events/friend_request.c +++ b/toxcore/events/friend_request.c @@ -7,6 +7,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" @@ -81,7 +82,7 @@ non_null() static void tox_event_friend_request_construct(Tox_Event_Friend_Request *friend_request) { *friend_request = (Tox_Event_Friend_Request) { - 0 + {0} }; } non_null() diff --git a/toxcore/events/friend_status.c b/toxcore/events/friend_status.c index e802d0b8b5..f06c7d14be 100644 --- a/toxcore/events/friend_status.c +++ b/toxcore/events/friend_status.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/friend_status_message.c b/toxcore/events/friend_status_message.c index 39f42cfb43..61ea64d377 100644 --- a/toxcore/events/friend_status_message.c +++ b/toxcore/events/friend_status_message.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/friend_typing.c b/toxcore/events/friend_typing.c index 5ae2ded630..620ae7966f 100644 --- a/toxcore/events/friend_typing.c +++ b/toxcore/events/friend_typing.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_custom_packet.c b/toxcore/events/group_custom_packet.c index 39436dba60..5067790335 100644 --- a/toxcore/events/group_custom_packet.c +++ b/toxcore/events/group_custom_packet.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_custom_private_packet.c b/toxcore/events/group_custom_private_packet.c index 0297c66b43..df76711c55 100644 --- a/toxcore/events/group_custom_private_packet.c +++ b/toxcore/events/group_custom_private_packet.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_invite.c b/toxcore/events/group_invite.c index 103dda180a..e6f6d3ce17 100644 --- a/toxcore/events/group_invite.c +++ b/toxcore/events/group_invite.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_join_fail.c b/toxcore/events/group_join_fail.c index 07ec596d8a..d6e3ffb2bc 100644 --- a/toxcore/events/group_join_fail.c +++ b/toxcore/events/group_join_fail.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_message.c b/toxcore/events/group_message.c index e24c039b71..e685d7a233 100644 --- a/toxcore/events/group_message.c +++ b/toxcore/events/group_message.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_moderation.c b/toxcore/events/group_moderation.c index 339a84c3d7..d9a1a33a19 100644 --- a/toxcore/events/group_moderation.c +++ b/toxcore/events/group_moderation.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_password.c b/toxcore/events/group_password.c index 9776fffbf9..70110eeb96 100644 --- a/toxcore/events/group_password.c +++ b/toxcore/events/group_password.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_peer_exit.c b/toxcore/events/group_peer_exit.c index 4653e5fa67..16add3b0b2 100644 --- a/toxcore/events/group_peer_exit.c +++ b/toxcore/events/group_peer_exit.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_peer_join.c b/toxcore/events/group_peer_join.c index 48a745c96e..036a35cb84 100644 --- a/toxcore/events/group_peer_join.c +++ b/toxcore/events/group_peer_join.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_peer_limit.c b/toxcore/events/group_peer_limit.c index 3a0326c108..985e266741 100644 --- a/toxcore/events/group_peer_limit.c +++ b/toxcore/events/group_peer_limit.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_peer_name.c b/toxcore/events/group_peer_name.c index d41d594d94..40e81d4919 100644 --- a/toxcore/events/group_peer_name.c +++ b/toxcore/events/group_peer_name.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_peer_status.c b/toxcore/events/group_peer_status.c index 6e437b0dd2..dc11ffa28c 100644 --- a/toxcore/events/group_peer_status.c +++ b/toxcore/events/group_peer_status.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_privacy_state.c b/toxcore/events/group_privacy_state.c index 939a71290d..15ae05464b 100644 --- a/toxcore/events/group_privacy_state.c +++ b/toxcore/events/group_privacy_state.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_private_message.c b/toxcore/events/group_private_message.c index f3e21375c1..404fb2a223 100644 --- a/toxcore/events/group_private_message.c +++ b/toxcore/events/group_private_message.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_self_join.c b/toxcore/events/group_self_join.c index b80667a6d1..5129f142c3 100644 --- a/toxcore/events/group_self_join.c +++ b/toxcore/events/group_self_join.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_topic.c b/toxcore/events/group_topic.c index fcca024863..d7e0bf37b5 100644 --- a/toxcore/events/group_topic.c +++ b/toxcore/events/group_topic.c @@ -8,6 +8,7 @@ #include #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_topic_lock.c b/toxcore/events/group_topic_lock.c index 27e94f612a..a859d41251 100644 --- a/toxcore/events/group_topic_lock.c +++ b/toxcore/events/group_topic_lock.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/group_voice_state.c b/toxcore/events/group_voice_state.c index 8f41f69759..91c13b16c8 100644 --- a/toxcore/events/group_voice_state.c +++ b/toxcore/events/group_voice_state.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/events/self_connection_status.c b/toxcore/events/self_connection_status.c index 1b1175ed3b..8ecf169cd7 100644 --- a/toxcore/events/self_connection_status.c +++ b/toxcore/events/self_connection_status.c @@ -6,6 +6,7 @@ #include +#include "../attributes.h" #include "../bin_pack.h" #include "../bin_unpack.h" #include "../ccompat.h" diff --git a/toxcore/forwarding.c b/toxcore/forwarding.c index 37a0f84191..18ff3203fc 100644 --- a/toxcore/forwarding.c +++ b/toxcore/forwarding.c @@ -9,6 +9,7 @@ #include #include "DHT.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "logger.h" diff --git a/toxcore/forwarding.h b/toxcore/forwarding.h index cf063ba2d1..655779f0a4 100644 --- a/toxcore/forwarding.h +++ b/toxcore/forwarding.h @@ -6,6 +6,10 @@ #define C_TOXCORE_TOXCORE_FORWARDING_H #include "DHT.h" +#include "attributes.h" +#include "crypto_core.h" +#include "logger.h" +#include "mono_time.h" #include "network.h" #ifdef __cplusplus diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index 4fce75bc42..cc521bea06 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c @@ -14,12 +14,15 @@ #include "DHT.h" #include "LAN_discovery.h" #include "TCP_connection.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "logger.h" #include "mono_time.h" #include "net_crypto.h" #include "network.h" +#include "onion.h" +#include "onion_announce.h" #include "onion_client.h" #include "util.h" diff --git a/toxcore/friend_connection.h b/toxcore/friend_connection.h index 03bb5634ff..efbb668630 100644 --- a/toxcore/friend_connection.h +++ b/toxcore/friend_connection.h @@ -9,9 +9,15 @@ #ifndef C_TOXCORE_TOXCORE_FRIEND_CONNECTION_H #define C_TOXCORE_TOXCORE_FRIEND_CONNECTION_H +#include + #include "DHT.h" #include "LAN_discovery.h" +#include "attributes.h" +#include "logger.h" +#include "mono_time.h" #include "net_crypto.h" +#include "network.h" #include "onion_client.h" #define MAX_FRIEND_CONNECTION_CALLBACKS 2 diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index fdfcde8bf8..447dd393bd 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c @@ -11,9 +11,13 @@ #include #include +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "friend_connection.h" +#include "network.h" +#include "onion.h" +#include "onion_announce.h" #include "onion_client.h" /** diff --git a/toxcore/friend_requests.h b/toxcore/friend_requests.h index 433d8fb93c..a78a570dfa 100644 --- a/toxcore/friend_requests.h +++ b/toxcore/friend_requests.h @@ -9,6 +9,9 @@ #ifndef C_TOXCORE_TOXCORE_FRIEND_REQUESTS_H #define C_TOXCORE_TOXCORE_FRIEND_REQUESTS_H +#include + +#include "attributes.h" #include "friend_connection.h" #define MAX_FRIEND_REQUEST_DATA_SIZE (ONION_CLIENT_MAX_DATA_SIZE - (1 + sizeof(uint32_t))) diff --git a/toxcore/group.c b/toxcore/group.c index acd263a961..24cacea108 100644 --- a/toxcore/group.c +++ b/toxcore/group.c @@ -14,6 +14,7 @@ #include "DHT.h" #include "Messenger.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "friend_connection.h" diff --git a/toxcore/group.h b/toxcore/group.h index 34ec6016f2..78c3dfd0fd 100644 --- a/toxcore/group.h +++ b/toxcore/group.h @@ -9,7 +9,14 @@ #ifndef C_TOXCORE_TOXCORE_GROUP_H #define C_TOXCORE_TOXCORE_GROUP_H +#include +#include + #include "Messenger.h" +#include "attributes.h" +#include "crypto_core.h" +#include "mono_time.h" +#include "state.h" typedef enum Groupchat_Type { GROUPCHAT_TYPE_TEXT, diff --git a/toxcore/group_announce.c b/toxcore/group_announce.c index 0aa704aeda..8066dfa1d0 100644 --- a/toxcore/group_announce.c +++ b/toxcore/group_announce.c @@ -9,7 +9,9 @@ #include #include "DHT.h" +#include "attributes.h" #include "ccompat.h" +#include "crypto_core.h" #include "logger.h" #include "mono_time.h" #include "network.h" diff --git a/toxcore/group_announce.h b/toxcore/group_announce.h index 0fc00976c8..77b9326118 100644 --- a/toxcore/group_announce.h +++ b/toxcore/group_announce.h @@ -10,8 +10,14 @@ #define C_TOXCORE_TOXCORE_GROUP_ANNOUNCE_H #include +#include #include "DHT.h" +#include "attributes.h" +#include "crypto_core.h" +#include "logger.h" +#include "mono_time.h" +#include "network.h" #ifdef __cplusplus extern "C" { diff --git a/toxcore/group_chats.c b/toxcore/group_chats.c index 6b595c06cc..873cadca23 100644 --- a/toxcore/group_chats.c +++ b/toxcore/group_chats.c @@ -18,6 +18,7 @@ #include "DHT.h" #include "Messenger.h" #include "TCP_connection.h" +#include "attributes.h" #include "bin_pack.h" #include "bin_unpack.h" #include "ccompat.h" diff --git a/toxcore/group_chats.h b/toxcore/group_chats.h index 678221aca1..e9ce39862d 100644 --- a/toxcore/group_chats.h +++ b/toxcore/group_chats.h @@ -14,12 +14,15 @@ #include #include "TCP_connection.h" +#include "attributes.h" #include "bin_pack.h" #include "bin_unpack.h" +#include "crypto_core.h" #include "group_announce.h" #include "group_common.h" #include "group_connection.h" #include "logger.h" +#include "network.h" #define GC_PING_TIMEOUT 12 #define GC_SEND_IP_PORT_INTERVAL (GC_PING_TIMEOUT * 5) diff --git a/toxcore/group_common.h b/toxcore/group_common.h index 1db66c045b..ae789fca0a 100644 --- a/toxcore/group_common.h +++ b/toxcore/group_common.h @@ -14,7 +14,13 @@ #include "DHT.h" #include "TCP_connection.h" +#include "attributes.h" +#include "crypto_core.h" #include "group_moderation.h" +#include "logger.h" +#include "mem.h" +#include "mono_time.h" +#include "network.h" #define MAX_GC_PART_MESSAGE_SIZE 128 #define MAX_GC_NICK_SIZE 128 diff --git a/toxcore/group_connection.c b/toxcore/group_connection.c index 9abf73e63e..000f1d51a9 100644 --- a/toxcore/group_connection.c +++ b/toxcore/group_connection.c @@ -16,6 +16,7 @@ #include "DHT.h" #include "TCP_connection.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "group_chats.h" diff --git a/toxcore/group_connection.h b/toxcore/group_connection.h index ec78f9dd5b..e34551c182 100644 --- a/toxcore/group_connection.h +++ b/toxcore/group_connection.h @@ -10,7 +10,14 @@ #ifndef C_TOXCORE_TOXCORE_GROUP_CONNECTION_H #define C_TOXCORE_TOXCORE_GROUP_CONNECTION_H +#include "DHT.h" +#include "TCP_connection.h" +#include "attributes.h" +#include "crypto_core.h" #include "group_common.h" +#include "logger.h" +#include "mono_time.h" +#include "network.h" /* Max number of TCP relays we share with a peer on handshake */ #define GCC_MAX_TCP_SHARED_RELAYS 3 diff --git a/toxcore/group_moderation.c b/toxcore/group_moderation.c index 12893419ef..47d2d0e659 100644 --- a/toxcore/group_moderation.c +++ b/toxcore/group_moderation.c @@ -16,6 +16,7 @@ #include #include "DHT.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "logger.h" diff --git a/toxcore/group_moderation.h b/toxcore/group_moderation.h index ecf1c2ffa1..eeab32fc0a 100644 --- a/toxcore/group_moderation.h +++ b/toxcore/group_moderation.h @@ -14,7 +14,10 @@ #include #include "DHT.h" +#include "attributes.h" +#include "crypto_core.h" #include "logger.h" +#include "mem.h" #ifdef __cplusplus extern "C" { diff --git a/toxcore/group_onion_announce.c b/toxcore/group_onion_announce.c index 16368e5cf6..d05db09a07 100644 --- a/toxcore/group_onion_announce.c +++ b/toxcore/group_onion_announce.c @@ -8,6 +8,8 @@ #include #include +#include "DHT.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "group_announce.h" @@ -15,6 +17,7 @@ #include "mono_time.h" #include "network.h" #include "onion_announce.h" +#include "timed_auth.h" static_assert(GCA_ANNOUNCE_MAX_SIZE <= ONION_MAX_EXTRA_DATA_SIZE, "GC_Announce does not fit into the onion packet extra data"); diff --git a/toxcore/group_onion_announce.h b/toxcore/group_onion_announce.h index cb1e51e1d3..5fbac02e0a 100644 --- a/toxcore/group_onion_announce.h +++ b/toxcore/group_onion_announce.h @@ -6,6 +6,8 @@ #ifndef C_TOXCORE_TOXCORE_GROUP_ONION_ANNOUNCE_H #define C_TOXCORE_TOXCORE_GROUP_ONION_ANNOUNCE_H +#include "attributes.h" +#include "crypto_core.h" #include "group_announce.h" #include "onion_announce.h" diff --git a/toxcore/group_pack.c b/toxcore/group_pack.c index f0351650a8..fd70238771 100644 --- a/toxcore/group_pack.c +++ b/toxcore/group_pack.c @@ -14,12 +14,15 @@ #include #include "DHT.h" +#include "attributes.h" #include "bin_pack.h" #include "bin_unpack.h" #include "ccompat.h" +#include "crypto_core.h" #include "group_common.h" #include "group_moderation.h" #include "logger.h" +#include "network.h" #include "util.h" bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out) diff --git a/toxcore/group_pack.h b/toxcore/group_pack.h index f6cef30e4b..03252fb86d 100644 --- a/toxcore/group_pack.h +++ b/toxcore/group_pack.h @@ -12,6 +12,7 @@ #include +#include "attributes.h" #include "bin_pack.h" #include "bin_unpack.h" #include "group_common.h" diff --git a/toxcore/list.c b/toxcore/list.c index 11b0c24a47..34672e3500 100644 --- a/toxcore/list.c +++ b/toxcore/list.c @@ -15,6 +15,7 @@ #include #include +#include "attributes.h" #include "ccompat.h" /** diff --git a/toxcore/logger.c b/toxcore/logger.c index 88e46625c1..67fa52330b 100644 --- a/toxcore/logger.c +++ b/toxcore/logger.c @@ -13,6 +13,7 @@ #include #include +#include "attributes.h" #include "ccompat.h" struct Logger { diff --git a/toxcore/mem.c b/toxcore/mem.c index fbced73559..bddc335b82 100644 --- a/toxcore/mem.c +++ b/toxcore/mem.c @@ -7,6 +7,7 @@ #include +#include "attributes.h" #include "ccompat.h" nullable(1) diff --git a/toxcore/mem_test_util.cc b/toxcore/mem_test_util.cc index 874bc66b61..02ade8fc68 100644 --- a/toxcore/mem_test_util.cc +++ b/toxcore/mem_test_util.cc @@ -2,6 +2,9 @@ #include +#include "mem.h" +#include "test_util.hh" + Memory_Funcs const Memory_Class::vtable = { Method::invoke<&Memory_Class::malloc>, Method::invoke<&Memory_Class::calloc>, diff --git a/toxcore/mono_time.c b/toxcore/mono_time.c index 414370f66a..d1e6adaef0 100644 --- a/toxcore/mono_time.c +++ b/toxcore/mono_time.c @@ -32,6 +32,7 @@ #include #include +#include "attributes.h" #include "ccompat.h" #include "mem.h" #include "util.h" diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 28b70d0fc2..f30dce130b 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -16,6 +16,7 @@ #include "LAN_discovery.h" #include "TCP_client.h" #include "TCP_connection.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "list.h" diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index 2351a7901f..1183222051 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h @@ -13,8 +13,14 @@ #include "DHT.h" #include "LAN_discovery.h" +#include "TCP_client.h" #include "TCP_connection.h" +#include "attributes.h" +#include "crypto_core.h" #include "logger.h" +#include "mem.h" +#include "mono_time.h" +#include "network.h" /*** Crypto payloads. */ diff --git a/toxcore/network.c b/toxcore/network.c index 1442f1a586..6d1a099ffa 100644 --- a/toxcore/network.c +++ b/toxcore/network.c @@ -81,6 +81,7 @@ #include #include +#include "attributes.h" #include "bin_pack.h" #include "ccompat.h" #include "logger.h" diff --git a/toxcore/network.h b/toxcore/network.h index 6aea1cb33c..76ede44039 100644 --- a/toxcore/network.h +++ b/toxcore/network.h @@ -13,6 +13,7 @@ #include // size_t #include // uint*_t +#include "attributes.h" #include "bin_pack.h" #include "logger.h" #include "mem.h" diff --git a/toxcore/network_test_util.cc b/toxcore/network_test_util.cc index 1f34e086ae..8db0136b14 100644 --- a/toxcore/network_test_util.cc +++ b/toxcore/network_test_util.cc @@ -2,6 +2,10 @@ #include +#include "crypto_core.h" +#include "network.h" +#include "test_util.hh" + Network_Funcs const Network_Class::vtable = { Method::invoke<&Network_Class::close>, Method::invoke<&Network_Class::accept>, diff --git a/toxcore/onion.c b/toxcore/onion.c index 802fb34aeb..1339d240bf 100644 --- a/toxcore/onion.c +++ b/toxcore/onion.c @@ -12,6 +12,7 @@ #include #include "DHT.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "logger.h" diff --git a/toxcore/onion.h b/toxcore/onion.h index 0bc59d70e7..d0ff5703bd 100644 --- a/toxcore/onion.h +++ b/toxcore/onion.h @@ -10,8 +10,12 @@ #define C_TOXCORE_TOXCORE_ONION_H #include "DHT.h" +#include "attributes.h" +#include "crypto_core.h" #include "logger.h" +#include "mem.h" #include "mono_time.h" +#include "network.h" #include "shared_key_cache.h" typedef int onion_recv_1_cb(void *object, const IP_Port *dest, const uint8_t *data, uint16_t length); diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index d3699ab09d..b445852f2d 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c @@ -14,6 +14,7 @@ #include "DHT.h" #include "LAN_discovery.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "logger.h" diff --git a/toxcore/onion_announce.h b/toxcore/onion_announce.h index f8eb9e470d..94f6d92eea 100644 --- a/toxcore/onion_announce.h +++ b/toxcore/onion_announce.h @@ -9,7 +9,13 @@ #ifndef C_TOXCORE_TOXCORE_ONION_ANNOUNCE_H #define C_TOXCORE_TOXCORE_ONION_ANNOUNCE_H +#include "DHT.h" +#include "attributes.h" +#include "crypto_core.h" #include "logger.h" +#include "mem.h" +#include "mono_time.h" +#include "network.h" #include "onion.h" #include "timed_auth.h" diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 94591319b6..bc249a125c 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c @@ -16,8 +16,10 @@ #include "DHT.h" #include "LAN_discovery.h" #include "TCP_connection.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" +#include "group_announce.h" #include "group_onion_announce.h" #include "logger.h" #include "mem.h" @@ -27,6 +29,7 @@ #include "onion.h" #include "onion_announce.h" #include "ping_array.h" +#include "timed_auth.h" #include "util.h" /** @brief defines for the array size and timeout for onion announce packets. */ diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h index c0bf37ddf7..d64bcc30cd 100644 --- a/toxcore/onion_client.h +++ b/toxcore/onion_client.h @@ -12,7 +12,14 @@ #include +#include "DHT.h" +#include "attributes.h" +#include "crypto_core.h" +#include "logger.h" +#include "mem.h" +#include "mono_time.h" #include "net_crypto.h" +#include "network.h" #include "onion_announce.h" #include "ping_array.h" diff --git a/toxcore/ping.c b/toxcore/ping.c index dc7658a216..efb4b02971 100644 --- a/toxcore/ping.c +++ b/toxcore/ping.c @@ -12,6 +12,7 @@ #include #include "DHT.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "mem.h" diff --git a/toxcore/ping.h b/toxcore/ping.h index 55ed44d399..b0339ec75d 100644 --- a/toxcore/ping.h +++ b/toxcore/ping.h @@ -13,6 +13,10 @@ #include #include "DHT.h" +#include "attributes.h" +#include "crypto_core.h" +#include "mem.h" +#include "mono_time.h" #include "network.h" typedef struct Ping Ping; diff --git a/toxcore/ping_array.c b/toxcore/ping_array.c index 6ba1cf68c8..c40215ea47 100644 --- a/toxcore/ping_array.c +++ b/toxcore/ping_array.c @@ -10,6 +10,7 @@ #include +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "mem.h" diff --git a/toxcore/ping_array.h b/toxcore/ping_array.h index 2c3d2737f3..3e50e66876 100644 --- a/toxcore/ping_array.h +++ b/toxcore/ping_array.h @@ -12,6 +12,7 @@ #include #include +#include "attributes.h" #include "crypto_core.h" #include "mem.h" #include "mono_time.h" diff --git a/toxcore/shared_key_cache.c b/toxcore/shared_key_cache.c index b52869b7a8..3d5769a4a3 100644 --- a/toxcore/shared_key_cache.c +++ b/toxcore/shared_key_cache.c @@ -7,6 +7,7 @@ #include #include // memcpy(...) +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "logger.h" diff --git a/toxcore/shared_key_cache.h b/toxcore/shared_key_cache.h index 1ff341ad72..18536e07ec 100644 --- a/toxcore/shared_key_cache.h +++ b/toxcore/shared_key_cache.h @@ -7,6 +7,7 @@ #include // uint*_t +#include "attributes.h" #include "crypto_core.h" #include "logger.h" #include "mem.h" diff --git a/toxcore/state.h b/toxcore/state.h index e070f3a279..ebe0c37221 100644 --- a/toxcore/state.h +++ b/toxcore/state.h @@ -17,6 +17,7 @@ #ifndef C_TOXCORE_TOXCORE_STATE_H #define C_TOXCORE_TOXCORE_STATE_H +#include "attributes.h" #include "logger.h" #ifdef __cplusplus diff --git a/toxcore/timed_auth.c b/toxcore/timed_auth.c index 8af0df5466..415cec2bc8 100644 --- a/toxcore/timed_auth.c +++ b/toxcore/timed_auth.c @@ -5,6 +5,7 @@ #include +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "mono_time.h" diff --git a/toxcore/timed_auth.h b/toxcore/timed_auth.h index 6f7c4d3295..bb19570872 100644 --- a/toxcore/timed_auth.h +++ b/toxcore/timed_auth.h @@ -4,6 +4,7 @@ #ifndef C_TOXCORE_TOXCORE_TIMED_AUTH_H #define C_TOXCORE_TOXCORE_TIMED_AUTH_H +#include "attributes.h" #include "crypto_core.h" #include "mono_time.h" diff --git a/toxcore/tox.c b/toxcore/tox.c index b899e84dd8..8b26bb022a 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -18,6 +18,7 @@ #include "DHT.h" #include "Messenger.h" #include "TCP_client.h" +#include "attributes.h" #include "ccompat.h" #include "crypto_core.h" #include "friend_requests.h" diff --git a/toxcore/tox_dispatch.c b/toxcore/tox_dispatch.c index 64a7e66599..dac2ae76d2 100644 --- a/toxcore/tox_dispatch.c +++ b/toxcore/tox_dispatch.c @@ -6,6 +6,7 @@ #include +#include "attributes.h" #include "ccompat.h" #include "events/events_alloc.h" // IWYU pragma: keep #include "tox.h" diff --git a/toxcore/tox_dispatch.h b/toxcore/tox_dispatch.h index 85a1cfe21e..1a21a7593a 100644 --- a/toxcore/tox_dispatch.h +++ b/toxcore/tox_dispatch.h @@ -5,6 +5,7 @@ #ifndef C_TOXCORE_TOXCORE_TOX_DISPATCH_H #define C_TOXCORE_TOXCORE_TOX_DISPATCH_H +#include "tox.h" #include "tox_events.h" #ifdef __cplusplus diff --git a/toxcore/tox_event.c b/toxcore/tox_event.c index edade65b3f..bb2000d806 100644 --- a/toxcore/tox_event.c +++ b/toxcore/tox_event.c @@ -6,6 +6,7 @@ #include +#include "attributes.h" #include "bin_pack.h" #include "bin_unpack.h" #include "ccompat.h" diff --git a/toxcore/tox_events.c b/toxcore/tox_events.c index d8f22d9f2b..3ab709301a 100644 --- a/toxcore/tox_events.c +++ b/toxcore/tox_events.c @@ -7,6 +7,7 @@ #include #include +#include "attributes.h" #include "bin_pack.h" #include "bin_unpack.h" #include "ccompat.h" diff --git a/toxcore/tox_struct.h b/toxcore/tox_struct.h index 5b0de20f6b..bd42fcce8d 100644 --- a/toxcore/tox_struct.h +++ b/toxcore/tox_struct.h @@ -6,8 +6,11 @@ #ifndef C_TOXCORE_TOXCORE_TOX_STRUCT_H #define C_TOXCORE_TOXCORE_TOX_STRUCT_H +#include + #include "Messenger.h" #include "mem.h" +#include "mono_time.h" #include "tox.h" #include "tox_private.h" diff --git a/toxcore/tox_unpack.c b/toxcore/tox_unpack.c index 8f30824fc8..9ee95db77a 100644 --- a/toxcore/tox_unpack.c +++ b/toxcore/tox_unpack.c @@ -6,6 +6,7 @@ #include +#include "attributes.h" #include "bin_unpack.h" #include "tox.h"