cleanup: Make all .c files include the headers they need.

This commit is contained in:
iphydf 2023-12-26 23:56:54 +00:00
parent ef4897a898
commit fad6e4e173
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
65 changed files with 272 additions and 88 deletions

View File

@ -35,8 +35,12 @@ CheckOptions:
value: lower_case
- key: llvmlibc-restrict-system-libc-headers.Includes
value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,limits.h,linux/netdevice.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdarg.h,stdbool.h,stdint.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h"
value: "arpa/inet.h,assert.h,ctype.h,errno.h,fcntl.h,getopt.h,libconfig.h,limits.h,linux/if.h,math.h,netdb.h,netinet/in.h,opus.h,pthread.h,signal.h,sodium/crypto_scalarmult_curve25519.h,sodium.h,sodium/randombytes.h,stdarg.h,stdbool.h,stdint.h,stdio.h,stdlib.h,string.h,sys/ioctl.h,syslog.h,sys/resource.h,sys/socket.h,sys/stat.h,sys/time.h,sys/types.h,time.h,unistd.h,vpx/vp8cx.h,vpx/vp8dx.h,vpx/vpx_decoder.h,vpx/vpx_encoder.h,vpx/vpx_image.h"
- key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
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.

View File

@ -27,7 +27,6 @@ branches:
- "ci/circleci: bazel-msan"
- "ci/circleci: bazel-tsan"
- "ci/circleci: clang-analyze"
- "ci/circleci: clang-tidy"
- "ci/circleci: cpplint"
- "ci/circleci: infer"
- "ci/circleci: static-analysis"
@ -35,6 +34,8 @@ branches:
- "ci/circleci: ubsan"
- "cimple"
- "cimplefmt"
- "clang-tidy"
- "cppcheck"
- "CodeFactor"
- "code-review/reviewable"
- "common / buildifier"

View File

@ -21,13 +21,11 @@ cc_binary(
"//c-toxcore/toxcore:Messenger",
"//c-toxcore/toxcore:TCP_server",
"//c-toxcore/toxcore:ccompat",
"//c-toxcore/toxcore:friend_requests",
"//c-toxcore/toxcore:group_onion_announce",
"//c-toxcore/toxcore:logger",
"//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore:network",
"//c-toxcore/toxcore:onion_announce",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:util",
],
)

View File

@ -16,12 +16,17 @@
#include "../toxcore/DHT.h"
#include "../toxcore/LAN_discovery.h"
#include "../toxcore/ccompat.h"
#include "../toxcore/friend_requests.h"
#include "../toxcore/crypto_core.h"
#include "../toxcore/forwarding.h"
#include "../toxcore/group_announce.h"
#include "../toxcore/group_onion_announce.h"
#include "../toxcore/logger.h"
#include "../toxcore/mem.h"
#include "../toxcore/mono_time.h"
#include "../toxcore/network.h"
#include "../toxcore/onion.h"
#include "../toxcore/onion_announce.h"
#include "../toxcore/tox.h"
#include "../toxcore/util.h"
#define TCP_RELAY_ENABLED

View File

@ -8,38 +8,47 @@ ERRORS="*"
# TODO(iphydf): Fix these.
ERRORS="$ERRORS,-cert-err34-c"
ERRORS="$ERRORS,-cert-str34-c"
ERRORS="$ERRORS,-readability-suspicious-call-argument"
# TODO(iphydf): Fix once cimple 0.0.19 is released.
CHECKS="$CHECKS,-google-readability-casting"
# TODO(iphydf): Fix these.
CHECKS="$CHECKS,-bugprone-switch-missing-default-case"
CHECKS="$CHECKS,-misc-include-cleaner"
# TODO(iphydf): We might want some of these. For the ones we don't want, add a
# comment explaining why not.
CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding"
CHECKS="$CHECKS,-hicpp-signed-bitwise"
CHECKS="$CHECKS,-readability-function-cognitive-complexity"
# TODO(iphydf): Maybe fix these?
CHECKS="$CHECKS,-bugprone-easily-swappable-parameters"
CHECKS="$CHECKS,-bugprone-implicit-widening-of-multiplication-result"
CHECKS="$CHECKS,-bugprone-integer-division"
CHECKS="$CHECKS,-clang-analyzer-core.NullDereference"
CHECKS="$CHECKS,-clang-analyzer-valist.Uninitialized"
CHECKS="$CHECKS,-cppcoreguidelines-avoid-non-const-global-variables"
CHECKS="$CHECKS,-misc-no-recursion"
# TODO(iphydf): Only happens in bootstrap_daemon. Fix it.
CHECKS="$CHECKS,-cppcoreguidelines-avoid-non-const-global-variables"
# TODO(iphydf): Probably fix these.
CHECKS="$CHECKS,-cert-err33-c"
CHECKS="$CHECKS,-cppcoreguidelines-avoid-magic-numbers"
CHECKS="$CHECKS,-google-readability-casting"
CHECKS="$CHECKS,-modernize-macro-to-enum"
CHECKS="$CHECKS,-readability-magic-numbers"
# TODO(iphydf): We're using a lot of macros for constants. Should we convert
# all of them to enum?
CHECKS="$CHECKS,-modernize-macro-to-enum"
# Documented disabled checks. We don't want these for sure.
# =========================================================
# https://stackoverflow.com/questions/58672959/why-does-clang-tidy-say-vsnprintf-has-an-uninitialized-va-list-argument
CHECKS="$CHECKS,-clang-analyzer-valist.Uninitialized"
# We pass a lot of ints around, so many function parameters are some kind of
# int type that can be converted from another int type. We won't be getting
# away from that anytime soon.
CHECKS="$CHECKS,-bugprone-easily-swappable-parameters"
# Callback handlers often don't use all their parameters. There's
# IgnoreVirtual, but that doesn't work for C-style callbacks.
CHECKS="$CHECKS,-misc-unused-parameters"
@ -132,27 +141,46 @@ CHECKS="$CHECKS,-misc-static-assert"
set -eux
# TODO(iphydf): Add toxav.
DIRS=(
other/bootstrap_daemon/src
other
toxcore
toxcore/events
toxencryptsave
)
copy_files() {
find "${DIRS[@]}" \
-maxdepth 1 -type d -exec mkdir -p "$1/{}" \;
find "${DIRS[@]}" \
-maxdepth 1 -name "*.c" -exec cp "{}" "$1/{}" \;
}
run() {
echo "Running clang-tidy in variant '$*'"
EXTRA_ARGS=("$@")
for i in "${!EXTRA_ARGS[@]}"; do
EXTRA_ARGS[$i]="--extra-arg=${EXTRA_ARGS[$i]}"
done
find \
other/bootstrap_daemon/src \
other \
toxav \
toxcore \
toxcore/events \
toxencryptsave \
ls .clang-tidy
copy_files a
if ! find "${DIRS[@]}" \
-maxdepth 1 -name "*.c" -print0 \
| xargs -0 -n15 -P"$(nproc)" clang-tidy \
-p=_build \
--extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
"${EXTRA_ARGS[@]}" \
--fix \
--checks="$CHECKS" \
--warnings-as-errors="$ERRORS" \
--use-color
--use-color; then
copy_files b
colordiff -ru a b
rm -rf a b
false
fi
rm -rf a
}
cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

View File

@ -18,7 +18,6 @@ cc_binary(
"//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore:onion_announce",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:util",
"@libconfig",
],
)

View File

@ -1 +1 @@
793cce1916b0d406b8e337d1a5243dc71b07727974cc83a3ef39b7af6cbf6cdb /usr/local/bin/tox-bootstrapd
c93d2d972558f578c6893aa12c1dafadf8b3dbb959b68c22efbfe7ad00d20f88 /usr/local/bin/tox-bootstrapd

View File

@ -10,12 +10,12 @@
#include "command_line_arguments.h"
#include "global.h"
#include "log.h"
#include "../../../toxcore/ccompat.h"
#include <getopt.h>
#include <stdlib.h>
#include <string.h>

View File

@ -10,6 +10,7 @@
#include "config.h"
#include "config_defaults.h"
#include "global.h"
#include "log.h"
#include <stdio.h>
@ -18,6 +19,10 @@
#include <libconfig.h>
#include "../../../toxcore/DHT.h"
#include "../../../toxcore/ccompat.h"
#include "../../../toxcore/crypto_core.h"
#include "../../../toxcore/network.h"
#include "../../bootstrap_node_packets.h"
/**

View File

@ -3,6 +3,8 @@
* Copyright © 2015-2016 Tox project.
*/
#include <stdarg.h>
/*
* Tox DHT bootstrap daemon.
* Logging utility with support of multiple logging backends.

View File

@ -9,8 +9,11 @@
*/
#include "log_backend_stdout.h"
#include <stdarg.h>
#include <stdio.h>
#include "log.h"
static FILE *log_backend_stdout_level(LOG_LEVEL level)
{
switch (level) {

View File

@ -10,10 +10,12 @@
#include "log_backend_syslog.h"
#include "global.h"
#include "log.h"
#include "../../../toxcore/ccompat.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>

View File

@ -23,17 +23,24 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
// toxcore
#include "../../../toxcore/tox.h"
#include "../../../toxcore/DHT.h"
#include "../../../toxcore/LAN_discovery.h"
#include "../../../toxcore/TCP_server.h"
#include "../../../toxcore/announce.h"
#include "../../../toxcore/ccompat.h"
#include "../../../toxcore/crypto_core.h"
#include "../../../toxcore/forwarding.h"
#include "../../../toxcore/group_announce.h"
#include "../../../toxcore/group_onion_announce.h"
#include "../../../toxcore/logger.h"
#include "../../../toxcore/mem.h"
#include "../../../toxcore/mono_time.h"
#include "../../../toxcore/network.h"
#include "../../../toxcore/onion.h"
#include "../../../toxcore/onion_announce.h"
#include "../../../toxcore/util.h"
// misc
#include "../../bootstrap_node_packets.h"

View File

@ -12,6 +12,8 @@
#include <string.h>
#include "../toxcore/network.h"
#define INFO_REQUEST_PACKET_LENGTH 78
static uint32_t bootstrap_version;

View File

@ -5,6 +5,7 @@ RUN ["apk", "add", "--no-cache", \
"clang", \
"clang-extra-tools", \
"cmake", \
"colordiff", \
"libconfig-dev", \
"libsodium-dev", \
"libvpx-dev", \

View File

@ -16,13 +16,15 @@
#include "LAN_discovery.h"
#include "bin_pack.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "network.h"
#include "ping.h"
#include "ping_array.h"
#include "shared_key_cache.h"
#include "state.h"
#include "util.h"
/** The timeout after which a node is discarded completely. */
#define KILL_NODE_TIMEOUT (BAD_NODE_TIMEOUT + PING_INTERVAL)

View File

@ -32,7 +32,7 @@
#endif
#ifdef __linux__
#include <linux/netdevice.h>
#include <linux/if.h>
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
@ -41,7 +41,7 @@
#include "ccompat.h"
#include "crypto_core.h"
#include "util.h"
#include "network.h"
#define MAX_INTERFACES 16

View File

@ -10,17 +10,33 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "DHT.h"
#include "TCP_client.h"
#include "TCP_connection.h"
#include "TCP_server.h"
#include "announce.h"
#include "bin_pack.h"
#include "bin_unpack.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "friend_connection.h"
#include "friend_requests.h"
#include "group_announce.h"
#include "group_chats.h"
#include "group_common.h"
#include "group_onion_announce.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"
#include "util.h"

View File

@ -10,12 +10,17 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "TCP_common.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "network.h"
#include "util.h"
typedef struct TCP_Client_Conn {

View File

@ -5,10 +5,13 @@
#include "TCP_common.h"
#include <stdlib.h>
#include <string.h>
#include "ccompat.h"
#include "crypto_core.h"
#include "logger.h"
#include "mem.h"
#include "network.h"
void wipe_priority_list(const Memory *mem, TCP_Priority_List *p)
{

View File

@ -9,12 +9,17 @@
#include "TCP_connection.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "TCP_client.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "network.h"
#include "util.h"
struct TCP_Connections {

View File

@ -8,7 +8,6 @@
*/
#include "TCP_server.h"
#include <stdlib.h>
#include <string.h>
#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32)
#include <sys/ioctl.h>
@ -19,11 +18,17 @@
#include <unistd.h>
#endif
#include "DHT.h"
#include "TCP_common.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "list.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "util.h"
#include "network.h"
#include "onion.h"
#ifdef TCP_SERVER_USE_EPOLL
#define TCP_SOCKET_LISTENING 0
@ -909,7 +914,7 @@ static Socket new_listening_tcp_socket(const Logger *logger, const Network *ns,
if (!sock_valid(sock)) {
LOGGER_ERROR(logger, "TCP socket creation failed (family = %d)", family.value);
return net_invalid_socket;
return net_invalid_socket();
}
bool ok = set_socket_nonblock(ns, sock);
@ -930,7 +935,7 @@ static Socket new_listening_tcp_socket(const Logger *logger, const Network *ns,
port, family.value, error != nullptr ? error : "(null)");
net_kill_strerror(error);
kill_sock(ns, sock);
return net_invalid_socket;
return net_invalid_socket();
}
LOGGER_DEBUG(logger, "successfully bound to TCP port %d", port);

View File

@ -12,8 +12,15 @@
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "LAN_discovery.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "forwarding.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "network.h"
#include "shared_key_cache.h"
#include "timed_auth.h"
#include "util.h"
@ -427,7 +434,7 @@ static int create_reply_plain_store_announce_request(Announcements *announce,
const uint8_t *to_auth, uint16_t to_auth_length)
{
const int plain_len = (int)length - (CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE);
const int announcement_len = (int)plain_len - (TIMED_AUTH_SIZE + sizeof(uint32_t) + 1);
const int announcement_len = plain_len - (TIMED_AUTH_SIZE + sizeof(uint32_t) + 1);
const uint8_t *const data_public_key = data;

View File

@ -10,6 +10,7 @@
#include "../third_party/cmp/cmp.h"
#include "ccompat.h"
#include "logger.h"
struct Bin_Pack {
uint8_t *bytes;

View File

@ -2,3 +2,5 @@
* Copyright © 2022 The TokTok team.
*/
#include "ccompat.h"
static_assert(sizeof(int) >= 4, "toxcore does not support 16-bit platform");

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h"
#include "../bin_unpack.h"

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h"
#include "../bin_unpack.h"

View File

@ -8,6 +8,7 @@
#include <stdlib.h>
#include "../ccompat.h"
#include "../tox_events.h"
Tox_Events_State *tox_events_alloc(void *user_data)
{

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h"
#include "../bin_unpack.h"

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h"
#include "../bin_unpack.h"

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h"
#include "../bin_unpack.h"

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h"
#include "../bin_unpack.h"

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h"
#include "../bin_unpack.h"

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h"
#include "../bin_unpack.h"

View File

@ -6,7 +6,6 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../bin_pack.h"
#include "../bin_unpack.h"

View File

@ -10,6 +10,10 @@
#include "DHT.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "logger.h"
#include "mono_time.h"
#include "network.h"
#include "timed_auth.h"
struct Forwarding {

View File

@ -11,9 +11,16 @@
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "LAN_discovery.h"
#include "TCP_connection.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "logger.h"
#include "mono_time.h"
#include "util.h"
#include "net_crypto.h"
#include "network.h"
#include "onion_client.h"
#define PORTS_PER_DISCOVERY 10

View File

@ -12,7 +12,9 @@
#include <string.h>
#include "ccompat.h"
#include "util.h"
#include "crypto_core.h"
#include "friend_connection.h"
#include "onion_client.h"
/**
* NOTE: The following is just a temporary fix for the multiple friend requests received at the same time problem.

View File

@ -12,8 +12,16 @@
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "Messenger.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "friend_connection.h"
#include "group_common.h"
#include "logger.h"
#include "mono_time.h"
#include "net_crypto.h"
#include "network.h"
#include "state.h"
#include "util.h"

View File

@ -8,10 +8,11 @@
#include <stdlib.h>
#include <string.h>
#include "LAN_discovery.h"
#include "DHT.h"
#include "ccompat.h"
#include "logger.h"
#include "mono_time.h"
#include "util.h"
#include "network.h"
/**
* Removes `announces` from `gc_announces_list`.

View File

@ -9,23 +9,31 @@
#include "group_chats.h"
#include <assert.h>
#include <sodium.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "LAN_discovery.h"
#include "Messenger.h"
#include "TCP_connection.h"
#include "bin_pack.h"
#include "bin_unpack.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "friend_connection.h"
#include "group_announce.h"
#include "group_common.h"
#include "group_connection.h"
#include "group_moderation.h"
#include "group_pack.h"
#include "logger.h"
#include "mono_time.h"
#include "net_crypto.h"
#include "network.h"
#include "onion_announce.h"
#include "onion_client.h"
#include "util.h"
/* The minimum size of a plaintext group handshake packet */
@ -1374,7 +1382,7 @@ static int make_gc_shared_state_packet(const GC_Chat *chat, uint8_t *data, uint1
return -1;
}
return (int)(header_len + packed_len);
return header_len + packed_len;
}
/** @brief Creates a signature for the group's shared state in packed form.
@ -3241,7 +3249,7 @@ static int make_gc_sanctions_list_packet(const GC_Chat *chat, uint8_t *data, uin
return -1;
}
return (int)(length + packed_len);
return length + packed_len;
}
/** @brief Sends the sanctions list to peer.

View File

@ -15,11 +15,14 @@
#include <string.h>
#include "DHT.h"
#include "TCP_connection.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "group_chats.h"
#include "group_common.h"
#include "logger.h"
#include "mono_time.h"
#include "network.h"
#include "util.h"
/** Seconds since last direct UDP packet was received before the connection is considered dead */

View File

@ -15,9 +15,10 @@
#include <string.h>
#include <time.h>
#include "DHT.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "mono_time.h"
#include "logger.h"
#include "network.h"
#include "util.h"
@ -305,7 +306,7 @@ int sanctions_list_pack(uint8_t *data, uint16_t length, const Mod_Sanction *sanc
return -1;
}
return (int)(packed_len + cred_len);
return packed_len + cred_len;
}
uint16_t sanctions_creds_unpack(Mod_Sanction_Creds *creds, const uint8_t *data)
@ -457,7 +458,7 @@ static bool sanctions_list_validate_entry(const Moderation *moderation, const Mo
uint8_t packed_data[MOD_SANCTION_PACKED_SIZE];
const int packed_len = sanctions_list_pack(packed_data, sizeof(packed_data), sanction, 1, nullptr);
if (packed_len <= (int) SIGNATURE_SIZE) {
if (packed_len <= SIGNATURE_SIZE) {
return false;
}
@ -785,7 +786,7 @@ static bool sanctions_list_sign_entry(const Moderation *moderation, Mod_Sanction
uint8_t packed_data[MOD_SANCTION_PACKED_SIZE];
const int packed_len = sanctions_list_pack(packed_data, sizeof(packed_data), sanction, 1, nullptr);
if (packed_len <= (int) SIGNATURE_SIZE) {
if (packed_len <= SIGNATURE_SIZE) {
LOGGER_ERROR(moderation->log, "Failed to pack sanctions list: %d", packed_len);
return false;
}

View File

@ -9,6 +9,12 @@
#include <string.h>
#include "ccompat.h"
#include "crypto_core.h"
#include "group_announce.h"
#include "logger.h"
#include "mono_time.h"
#include "network.h"
#include "onion_announce.h"
static_assert(GCA_ANNOUNCE_MAX_SIZE <= ONION_MAX_EXTRA_DATA_SIZE,
"GC_Announce does not fit into the onion packet extra data");

View File

@ -13,9 +13,13 @@
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "bin_pack.h"
#include "bin_unpack.h"
#include "ccompat.h"
#include "group_common.h"
#include "group_moderation.h"
#include "logger.h"
#include "util.h"
bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out)
@ -428,7 +432,7 @@ static void save_pack_self_info(const GC_Chat *chat, Bin_Pack *bp)
bin_pack_u16(bp, self->nick_length); // 1
bin_pack_u08(bp, (uint8_t)self->role); // 2
bin_pack_u08(bp, (uint8_t)self->status); // 3
bin_pack_u08(bp, self->status); // 3
bin_pack_bin(bp, self->nick, self->nick_length); // 4
}

View File

@ -8,7 +8,6 @@
*/
#include "logger.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -26,12 +26,14 @@
#include <sys/time.h>
#endif
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
#include <assert.h>
#endif
#include <pthread.h>
#include <stdlib.h>
#include <time.h>
#include "ccompat.h"
#include "mem.h"
#include "util.h"
/** don't call into system billions of times for no reason */

View File

@ -10,13 +10,19 @@
*/
#include "net_crypto.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "LAN_discovery.h"
#include "TCP_client.h"
#include "TCP_connection.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "list.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "network.h"
#include "util.h"
typedef struct Packet_Data {

View File

@ -89,7 +89,7 @@
#include "ccompat.h"
#include "logger.h"
#include "mono_time.h"
#include "mem.h"
#include "util.h"
// Disable MSG_NOSIGNAL on systems not supporting it, e.g. Windows, FreeBSD
@ -366,7 +366,11 @@ IP6 get_ip6_loopback(void)
#define INVALID_SOCKET (-1)
#endif
const Socket net_invalid_socket = { (int)INVALID_SOCKET };
Socket net_invalid_socket(void)
{
const Socket invalid_socket = { (int)INVALID_SOCKET };
return invalid_socket;
}
Family net_family_unspec(void)
{
@ -460,7 +464,8 @@ bool net_family_is_tox_tcp_ipv6(Family family)
bool sock_valid(Socket sock)
{
return sock.sock != net_invalid_socket.sock;
const Socket invalid_socket = net_invalid_socket();
return sock.sock != invalid_socket.sock;
}
struct Network_Addr {

View File

@ -226,7 +226,7 @@ Socket net_socket(const Network *ns, Family domain, int type, int protocol);
*/
bool sock_valid(Socket sock);
extern const Socket net_invalid_socket;
Socket net_invalid_socket(void);
/**
* Calls send(sockfd, buf, len, MSG_NOSIGNAL).

View File

@ -9,12 +9,16 @@
#include "onion.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "util.h"
#include "network.h"
#include "shared_key_cache.h"
#define RETURN_1 ONION_RETURN_1
#define RETURN_2 ONION_RETURN_2

View File

@ -15,9 +15,14 @@
#include "DHT.h"
#include "LAN_discovery.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "network.h"
#include "onion.h"
#include "shared_key_cache.h"
#include "util.h"
#include "timed_auth.h"
#define PING_ID_TIMEOUT ONION_ANNOUNCE_TIMEOUT

View File

@ -13,10 +13,20 @@
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "LAN_discovery.h"
#include "TCP_connection.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "group_onion_announce.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 "ping_array.h"
#include "util.h"
/** @brief defines for the array size and timeout for onion announce packets. */

View File

@ -9,15 +9,15 @@
*/
#include "ping.h"
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "mem.h"
#include "mono_time.h"
#include "network.h"
#include "ping_array.h"
#include "util.h"
#define PING_NUM_MAX 512

View File

@ -8,13 +8,12 @@
*/
#include "ping_array.h"
#include <stdlib.h>
#include <string.h>
#include "ccompat.h"
#include "crypto_core.h"
#include "mem.h"
#include "mono_time.h"
#include "util.h"
typedef struct Ping_Array_Entry {
uint8_t *data;

View File

@ -4,12 +4,13 @@
#include "shared_key_cache.h"
#include <assert.h>
#include <stdint.h>
#include <string.h> // memcpy(...)
#include "ccompat.h"
#include "crypto_core.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
typedef struct Shared_Key {

View File

@ -7,6 +7,7 @@
#include <string.h>
#include "ccompat.h"
#include "logger.h"
/** state load/save */
int state_load(const Logger *log, state_load_cb *state_load_callback, void *outer,

View File

@ -6,6 +6,8 @@
#include <string.h>
#include "ccompat.h"
#include "crypto_core.h"
#include "mono_time.h"
non_null(1,6) nullable(4)
static void create_timed_auth_to_hash(const Mono_Time *mono_time, uint16_t timeout, bool previous, const uint8_t *data,

View File

@ -13,18 +13,24 @@
#include "tox.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "DHT.h"
#include "Messenger.h"
#include "TCP_client.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "friend_requests.h"
#include "group.h"
#include "group_chats.h"
#include "group_moderation.h"
#include "group_common.h"
#include "logger.h"
#include "mem.h"
#include "mono_time.h"
#include "net_crypto.h"
#include "network.h"
#include "onion_client.h"
#include "state.h"
#include "tox_private.h"
#include "tox_struct.h"

View File

@ -4,7 +4,6 @@
#include "tox.h"
#include <stdlib.h>
#include <string.h>
#include "ccompat.h"
#include "tox_private.h"

View File

@ -7,6 +7,8 @@
#include <stdlib.h>
#include "ccompat.h"
#include "tox.h"
#include "tox_events.h"
struct Tox_Dispatch {
tox_events_conference_connected_cb *conference_connected_callback;

View File

@ -5,16 +5,16 @@
#include "tox_events.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bin_pack.h"
#include "bin_unpack.h"
#include "ccompat.h"
#include "events/events_alloc.h"
#include "logger.h"
#include "mem.h"
#include "tox.h"
#include "tox_private.h"
#include "tox_struct.h"
/*****************************************************

View File

@ -10,10 +10,15 @@
#include <assert.h>
#include "DHT.h"
#include "ccompat.h"
#include "crypto_core.h"
#include "group_chats.h"
#include "group_common.h"
#include "mem.h"
#include "net_crypto.h"
#include "network.h"
#include "tox.h"
#include "tox_struct.h"
#define SET_ERROR_PARAMETER(param, x) \

View File

@ -7,7 +7,7 @@
#include <stdint.h>
#include "bin_unpack.h"
#include "ccompat.h"
#include "tox.h"
non_null()
static bool tox_conference_type_from_int(uint32_t value, Tox_Conference_Type *out)

View File

@ -13,11 +13,10 @@
#include "util.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "ccompat.h"
#include "mem.h"
bool is_power_of_2(uint64_t x)
{