cleanup: Add comment after every #endif.

This makes far-away endifs clearer, so we're applying the rule to all
endifs to be consistent.
This commit is contained in:
iphydf 2024-01-23 13:11:05 +00:00
parent ba99d4dc4b
commit 1cdcf938b9
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
78 changed files with 217 additions and 214 deletions

View File

@ -1 +1 @@
3acc3a1f08e67dac66d91657a36d98be397fa3f14bc4798d3349605e37a90fc3 /usr/local/bin/tox-bootstrapd 09cd2be2005d21ad9f146a59d4f7d7b2221a07d7b6e72a63387dc468ea477a1d /usr/local/bin/tox-bootstrapd

View File

@ -4,6 +4,7 @@ CIMPLE_FILES = [
"//c-toxcore/toxav:cimple_files", "//c-toxcore/toxav:cimple_files",
"//c-toxcore/toxcore:cimple_files", "//c-toxcore/toxcore:cimple_files",
"//c-toxcore/toxencryptsave:cimple_files", "//c-toxcore/toxencryptsave:cimple_files",
"//c-toxcore/third_party:cimple_files",
] ]
sh_test( sh_test(
@ -40,7 +41,6 @@ sh_test(
"-RTS", "-RTS",
], ],
data = CIMPLE_FILES + [ data = CIMPLE_FILES + [
"//c-toxcore/third_party:headers",
"//hs-tokstyle:headers", "//hs-tokstyle:headers",
"@libsodium//:headers", "@libsodium//:headers",
"@libvpx//:headers", "@libvpx//:headers",

View File

@ -21,7 +21,7 @@ int cmdline_parsefor_ipv46(int argc, char **argv, bool *ipv6enabled);
int use_test_rng(uint32_t seed); int use_test_rng(uint32_t seed);
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
#endif #endif

View File

@ -9,7 +9,10 @@ cc_library(
) )
filegroup( filegroup(
name = "headers", name = "cimple_files",
srcs = ["cmp/cmp.h"], srcs = [
"cmp/cmp.c",
"cmp/cmp.h",
],
visibility = ["//c-toxcore:__subpackages__"], visibility = ["//c-toxcore:__subpackages__"],
) )

2
third_party/cmp vendored

@ -1 +1 @@
Subproject commit e836703291392aba9db92b46fb47929521fac71f Subproject commit 065b1caed4bee66ef5f87f5ac3a9ee7a78f72386

View File

@ -70,4 +70,4 @@ void ac_iterate(ACSession *ac);
int ac_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg); int ac_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
int ac_reconfigure_encoder(ACSession *ac, uint32_t bit_rate, uint32_t sampling_rate, uint8_t channels); int ac_reconfigure_encoder(ACSession *ac, uint32_t bit_rate, uint32_t sampling_rate, uint8_t channels);
#endif // C_TOXCORE_TOXAV_AUDIO_H #endif /* C_TOXCORE_TOXAV_AUDIO_H */

View File

@ -20,4 +20,4 @@ void bwc_kill(BWController *bwc);
void bwc_add_lost(BWController *bwc, uint32_t bytes_lost); void bwc_add_lost(BWController *bwc, uint32_t bytes_lost);
void bwc_add_recv(BWController *bwc, uint32_t recv_bytes); void bwc_add_recv(BWController *bwc, uint32_t recv_bytes);
#endif // C_TOXCORE_TOXAV_BWCONTROLLER_H #endif /* C_TOXCORE_TOXAV_BWCONTROLLER_H */

View File

@ -61,4 +61,4 @@ int groupchat_disable_av(const Group_Chats *g_c, uint32_t conference_number);
/** Return whether A/V is enabled in the conference. */ /** Return whether A/V is enabled in the conference. */
bool groupchat_av_enabled(const Group_Chats *g_c, uint32_t conference_number); bool groupchat_av_enabled(const Group_Chats *g_c, uint32_t conference_number);
#endif // C_TOXCORE_TOXAV_GROUPAV_H #endif /* C_TOXCORE_TOXAV_GROUPAV_H */

View File

@ -144,4 +144,4 @@ int msi_answer(MSICall *call, uint8_t capabilities);
*/ */
int msi_change_capabilities(MSICall *call, uint8_t capabilities); int msi_change_capabilities(MSICall *call, uint8_t capabilities);
#endif // C_TOXCORE_TOXAV_MSI_H #endif /* C_TOXCORE_TOXAV_MSI_H */

View File

@ -25,7 +25,7 @@ uint16_t rb_size(const RingBuffer *b);
uint16_t rb_data(const RingBuffer *b, void **dest); uint16_t rb_data(const RingBuffer *b, void **dest);
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXAV_RING_BUFFER_H #endif /* C_TOXCORE_TOXAV_RING_BUFFER_H */

View File

@ -204,7 +204,7 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint32_t length,
bool is_keyframe, const Logger *log); bool is_keyframe, const Logger *log);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXAV_RTP_H #endif /* C_TOXCORE_TOXAV_RTP_H */

View File

@ -846,7 +846,7 @@ bool toxav_groupchat_av_enabled(Tox *tox, uint32_t groupnumber);
/** @} */ /** @} */
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
//!TOKSTYLE- //!TOKSTYLE-
@ -865,4 +865,4 @@ typedef enum Toxav_Friend_Call_State TOXAV_FRIEND_CALL_STATE;
#endif #endif
//!TOKSTYLE+ //!TOKSTYLE+
#endif // C_TOXCORE_TOXAV_TOXAV_H #endif /* C_TOXCORE_TOXAV_TOXAV_H */

View File

@ -140,7 +140,7 @@ static void vc_init_encoder_cfg(const Logger *log, vpx_codec_enc_cfg_t *cfg, int
cfg->rc_buf_initial_sz = 500; cfg->rc_buf_initial_sz = 500;
cfg->rc_buf_optimal_sz = 600; cfg->rc_buf_optimal_sz = 600;
cfg->rc_buf_sz = 1000; cfg->rc_buf_sz = 1000;
#endif #endif /* 0 */
} }
VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number, VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number,
@ -249,7 +249,7 @@ VCSession *vc_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t f
goto BASE_CLEANUP_1; goto BASE_CLEANUP_1;
} }
#endif #endif /* 0 */
vc->linfts = current_time_monotonic(mono_time); vc->linfts = current_time_monotonic(mono_time);
vc->lcfd = 60; vc->lcfd = 60;
vc->vcb = cb; vc->vcb = cb;

View File

@ -51,4 +51,4 @@ void vc_iterate(VCSession *vc);
int vc_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg); int vc_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist); int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist);
#endif // C_TOXCORE_TOXAV_VIDEO_H #endif /* C_TOXCORE_TOXAV_VIDEO_H */

View File

@ -585,7 +585,7 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed
#ifndef NDEBUG #ifndef NDEBUG
const uint32_t increment = ipp_size + CRYPTO_PUBLIC_KEY_SIZE; const uint32_t increment = ipp_size + CRYPTO_PUBLIC_KEY_SIZE;
assert(increment == PACKED_NODE_SIZE_IP4 || increment == PACKED_NODE_SIZE_IP6); assert(increment == PACKED_NODE_SIZE_IP4 || increment == PACKED_NODE_SIZE_IP6);
#endif #endif /* NDEBUG */
} }
if (processed_data_len != nullptr) { if (processed_data_len != nullptr) {
@ -829,7 +829,7 @@ static void get_close_nodes_inner(
continue; continue;
} }
#endif #endif /* CHECK_ANNOUNCE_NODE */
if (num_nodes < MAX_SENT_NODES) { if (num_nodes < MAX_SENT_NODES) {
memcpy(nodes_list[num_nodes].public_key, client->public_key, CRYPTO_PUBLIC_KEY_SIZE); memcpy(nodes_list[num_nodes].public_key, client->public_key, CRYPTO_PUBLIC_KEY_SIZE);
@ -1035,7 +1035,7 @@ static int handle_data_search_response(void *object, const IP_Port *source,
return 0; return 0;
} }
#endif #endif /* CHECK_ANNOUNCE_NODE */
/** @brief Is it ok to store node with public_key in client. /** @brief Is it ok to store node with public_key in client.
* *
@ -1180,7 +1180,7 @@ static bool add_to_close(DHT *dht, const uint8_t *public_key, const IP_Port *ip_
#ifdef CHECK_ANNOUNCE_NODE #ifdef CHECK_ANNOUNCE_NODE
client->announce_node = false; client->announce_node = false;
send_announce_ping(dht, public_key, ip_port); send_announce_ping(dht, public_key, ip_port);
#endif #endif /* CHECK_ANNOUNCE_NODE */
return true; return true;
} }
@ -2691,7 +2691,7 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw
#ifdef CHECK_ANNOUNCE_NODE #ifdef CHECK_ANNOUNCE_NODE
networking_registerhandler(dht->net, NET_PACKET_DATA_SEARCH_RESPONSE, &handle_data_search_response, dht); networking_registerhandler(dht->net, NET_PACKET_DATA_SEARCH_RESPONSE, &handle_data_search_response, dht);
#endif #endif /* CHECK_ANNOUNCE_NODE */
crypto_new_keypair(rng, dht->self_public_key, dht->self_secret_key); crypto_new_keypair(rng, dht->self_public_key, dht->self_secret_key);

View File

@ -169,7 +169,7 @@ typedef struct Client_data {
#ifdef CHECK_ANNOUNCE_NODE #ifdef CHECK_ANNOUNCE_NODE
/* Responded to data search? */ /* Responded to data search? */
bool announce_node; bool announce_node;
#endif #endif /* CHECK_ANNOUNCE_NODE */
} Client_data; } Client_data;
/*----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------*/
@ -381,7 +381,7 @@ bool node_addable_to_close_list(DHT *dht, const uint8_t *public_key, const IP_Po
/** Set node as announce node. */ /** Set node as announce node. */
non_null() non_null()
void set_announce_node(DHT *dht, const uint8_t *public_key); void set_announce_node(DHT *dht, const uint8_t *public_key);
#endif #endif /* CHECK_ANNOUNCE_NODE */
/** /**
* @brief Get the (maximum MAX_SENT_NODES) closest nodes to public_key we know * @brief Get the (maximum MAX_SENT_NODES) closest nodes to public_key we know
@ -558,7 +558,7 @@ non_null()
unsigned int ipport_self_copy(const DHT *dht, IP_Port *dest); unsigned int ipport_self_copy(const DHT *dht, IP_Port *dest);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif #endif /* C_TOXCORE_TOXCORE_DHT_H */

View File

@ -21,7 +21,7 @@
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <iphlpapi.h> #include <iphlpapi.h>
#endif #endif /* WIN32 */
#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
#include <netinet/in.h> #include <netinet/in.h>
@ -29,15 +29,15 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#endif #endif /* Linux/BSD */
#ifdef __linux__ #ifdef __linux__
#include <linux/if.h> #include <linux/if.h>
#endif #endif /* Linux */
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
#include <net/if.h> #include <net/if.h>
#endif #endif /* BSD */
#include "ccompat.h" #include "ccompat.h"
#include "crypto_core.h" #include "crypto_core.h"
@ -204,7 +204,7 @@ static Broadcast_Info *fetch_broadcast_info(const Network *ns)
return (Broadcast_Info *)calloc(1, sizeof(Broadcast_Info)); return (Broadcast_Info *)calloc(1, sizeof(Broadcast_Info));
} }
#endif #endif /* platforms */
/** @brief Send packet to all IPv4 broadcast addresses /** @brief Send packet to all IPv4 broadcast addresses
* *

View File

@ -53,4 +53,4 @@ bool ip_is_local(const IP *ip);
non_null() non_null()
bool ip_is_lan(const IP *ip); bool ip_is_lan(const IP *ip);
#endif // C_TOXCORE_TOXCORE_LAN_DISCOVERY_H #endif /* C_TOXCORE_TOXCORE_LAN_DISCOVERY_H */

View File

@ -2213,7 +2213,7 @@ static int m_handle_packet_file_sendrequest(Messenger *m, const int friendcon_id
return 0; return 0;
} }
#endif #endif /* UINT8_MAX >= MAX_CONCURRENT_FILE_PIPES */
uint64_t filesize; uint64_t filesize;
uint32_t file_type; uint32_t file_type;
@ -2281,7 +2281,7 @@ static int m_handle_packet_file_control(Messenger *m, const int friendcon_id, co
return 0; return 0;
} }
#endif #endif /* UINT8_MAX >= MAX_CONCURRENT_FILE_PIPES */
if (handle_filecontrol(m, friendcon_id, outbound, filenumber, control_type, data + 3, data_length - 3, userdata) == -1) { if (handle_filecontrol(m, friendcon_id, outbound, filenumber, control_type, data + 3, data_length - 3, userdata) == -1) {
// TODO(iphydf): Do something different here? Right now, this // TODO(iphydf): Do something different here? Right now, this
@ -2307,7 +2307,7 @@ static int m_handle_packet_file_data(Messenger *m, const int friendcon_id, const
return 0; return 0;
} }
#endif #endif /* UINT8_MAX >= MAX_CONCURRENT_FILE_PIPES */
struct File_Transfers *ft = &m->friendlist[friendcon_id].file_receiving[filenumber]; struct File_Transfers *ft = &m->friendlist[friendcon_id].file_receiving[filenumber];
@ -3117,7 +3117,7 @@ static uint8_t *friends_list_save(const Messenger *m, uint8_t *data)
assert(next_data - cur_data == friend_size()); assert(next_data - cur_data == friend_size());
#ifdef __LP64__ #ifdef __LP64__
assert(memcmp(cur_data, &temp, friend_size()) == 0); assert(memcmp(cur_data, &temp, friend_size()) == 0);
#endif #endif /* __LP64__ */
cur_data = next_data; cur_data = next_data;
++num; ++num;
} }

View File

@ -41,7 +41,7 @@ typedef enum Message_Type {
#ifndef MESSENGER_DEFINED #ifndef MESSENGER_DEFINED
#define MESSENGER_DEFINED #define MESSENGER_DEFINED
typedef struct Messenger Messenger; typedef struct Messenger Messenger;
#endif // MESSENGER_DEFINED #endif /* MESSENGER_DEFINED */
// Returns the size of the data // Returns the size of the data
typedef uint32_t m_state_size_cb(const Messenger *m); typedef uint32_t m_state_size_cb(const Messenger *m);
@ -890,4 +890,4 @@ uint32_t copy_friendlist(const Messenger *m, uint32_t *out_list, uint32_t list_s
non_null() non_null()
bool m_is_receiving_file(Messenger *m); bool m_is_receiving_file(Messenger *m);
#endif #endif /* C_TOXCORE_TOXCORE_MESSENGER_H */

View File

@ -151,4 +151,4 @@ non_null()
void oob_data_handler(TCP_Client_Connection *con, tcp_oob_data_cb *oob_data_callback, void *object); void oob_data_handler(TCP_Client_Connection *con, tcp_oob_data_cb *oob_data_callback, void *object);
#endif #endif /* C_TOXCORE_TOXCORE_TCP_CLIENT_H */

View File

@ -111,4 +111,4 @@ int read_packet_tcp_secure_connection(
const uint8_t *shared_key, uint8_t *recv_nonce, uint8_t *data, const uint8_t *shared_key, uint8_t *recv_nonce, uint8_t *data,
uint16_t max_len, const IP_Port *ip_port); uint16_t max_len, const IP_Port *ip_port);
#endif #endif /* C_TOXCORE_TOXCORE_TCP_COMMON_H */

View File

@ -310,4 +310,4 @@ void do_tcp_connections(const Logger *logger, TCP_Connections *tcp_c, void *user
nullable(1) nullable(1)
void kill_tcp_connections(TCP_Connections *tcp_c); void kill_tcp_connections(TCP_Connections *tcp_c);
#endif #endif /* C_TOXCORE_TOXCORE_TCP_CONNECTION_H */

View File

@ -11,12 +11,12 @@
#include <string.h> #include <string.h>
#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32) #if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32)
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif /* !WIN32 */
#ifdef TCP_SERVER_USE_EPOLL #ifdef TCP_SERVER_USE_EPOLL
#include <sys/epoll.h> #include <sys/epoll.h>
#include <unistd.h> #include <unistd.h>
#endif #endif /* TCP_SERVER_USE_EPOLL */
#include "DHT.h" #include "DHT.h"
#include "TCP_common.h" #include "TCP_common.h"
@ -35,7 +35,7 @@
#define TCP_SOCKET_INCOMING 1 #define TCP_SOCKET_INCOMING 1
#define TCP_SOCKET_UNCONFIRMED 2 #define TCP_SOCKET_UNCONFIRMED 2
#define TCP_SOCKET_CONFIRMED 3 #define TCP_SOCKET_CONFIRMED 3
#endif #endif /* TCP_SERVER_USE_EPOLL */
typedef struct TCP_Secure_Conn { typedef struct TCP_Secure_Conn {
uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE];
@ -72,7 +72,7 @@ struct TCP_Server {
#ifdef TCP_SERVER_USE_EPOLL #ifdef TCP_SERVER_USE_EPOLL
int efd; int efd;
uint64_t last_run_pinged; uint64_t last_run_pinged;
#endif #endif /* TCP_SERVER_USE_EPOLL */
Socket *socks_listening; Socket *socks_listening;
unsigned int num_listening_socks; unsigned int num_listening_socks;
@ -109,8 +109,8 @@ size_t tcp_server_listen_count(const TCP_Server *tcp_server)
#ifdef TCP_SERVER_USE_EPOLL #ifdef TCP_SERVER_USE_EPOLL
#ifndef EPOLLRDHUP #ifndef EPOLLRDHUP
#define EPOLLRDHUP 0x2000 #define EPOLLRDHUP 0x2000
#endif #endif /* EPOLLRDHUP */
#endif #endif /* TCP_SERVER_USE_EPOLL */
/** @brief Increase the size of the connection list /** @brief Increase the size of the connection list
* *
@ -991,7 +991,7 @@ TCP_Server *new_tcp_server(const Logger *logger, const Memory *mem, const Random
return nullptr; return nullptr;
} }
#endif #endif /* TCP_SERVER_USE_EPOLL */
const Family family = ipv6_enabled ? net_family_ipv6() : net_family_ipv4(); const Family family = ipv6_enabled ? net_family_ipv6() : net_family_ipv4();
@ -1012,7 +1012,7 @@ TCP_Server *new_tcp_server(const Logger *logger, const Memory *mem, const Random
continue; continue;
} }
#endif #endif /* TCP_SERVER_USE_EPOLL */
temp->socks_listening[temp->num_listening_socks] = sock; temp->socks_listening[temp->num_listening_socks] = sock;
++temp->num_listening_socks; ++temp->num_listening_socks;
@ -1057,7 +1057,7 @@ static void do_tcp_accept_new(TCP_Server *tcp_server)
} }
} }
} }
#endif #endif /* TCP_SERVER_USE_EPOLL */
non_null() non_null()
static int do_incoming(TCP_Server *tcp_server, uint32_t i) static int do_incoming(TCP_Server *tcp_server, uint32_t i)
@ -1174,7 +1174,7 @@ static void do_tcp_unconfirmed(TCP_Server *tcp_server, const Mono_Time *mono_tim
do_unconfirmed(tcp_server, mono_time, i); do_unconfirmed(tcp_server, mono_time, i);
} }
} }
#endif #endif /* TCP_SERVER_USE_EPOLL */
non_null() non_null()
static void do_tcp_confirmed(TCP_Server *tcp_server, const Mono_Time *mono_time) static void do_tcp_confirmed(TCP_Server *tcp_server, const Mono_Time *mono_time)
@ -1186,7 +1186,7 @@ static void do_tcp_confirmed(TCP_Server *tcp_server, const Mono_Time *mono_time)
} }
tcp_server->last_run_pinged = mono_time_get(mono_time); tcp_server->last_run_pinged = mono_time_get(mono_time);
#endif #endif /* TCP_SERVER_USE_EPOLL */
for (uint32_t i = 0; i < tcp_server->size_accepted_connections; ++i) { for (uint32_t i = 0; i < tcp_server->size_accepted_connections; ++i) {
TCP_Secure_Connection *conn = &tcp_server->accepted_connection_array[i]; TCP_Secure_Connection *conn = &tcp_server->accepted_connection_array[i];
@ -1229,7 +1229,7 @@ static void do_tcp_confirmed(TCP_Server *tcp_server, const Mono_Time *mono_time)
do_confirmed_recv(tcp_server, i); do_confirmed_recv(tcp_server, i);
#endif #endif /* TCP_SERVER_USE_EPOLL */
} }
} }
@ -1369,7 +1369,7 @@ static void do_tcp_epoll(TCP_Server *tcp_server, const Mono_Time *mono_time)
continue; continue;
} }
} }
#endif #endif /* TCP_SERVER_USE_EPOLL */
void do_tcp_server(TCP_Server *tcp_server, const Mono_Time *mono_time) void do_tcp_server(TCP_Server *tcp_server, const Mono_Time *mono_time)
{ {
@ -1380,7 +1380,7 @@ void do_tcp_server(TCP_Server *tcp_server, const Mono_Time *mono_time)
do_tcp_accept_new(tcp_server); do_tcp_accept_new(tcp_server);
do_tcp_incoming(tcp_server); do_tcp_incoming(tcp_server);
do_tcp_unconfirmed(tcp_server, mono_time); do_tcp_unconfirmed(tcp_server, mono_time);
#endif #endif /* TCP_SERVER_USE_EPOLL */
do_tcp_confirmed(tcp_server, mono_time); do_tcp_confirmed(tcp_server, mono_time);
} }
@ -1407,7 +1407,7 @@ void kill_tcp_server(TCP_Server *tcp_server)
#ifdef TCP_SERVER_USE_EPOLL #ifdef TCP_SERVER_USE_EPOLL
close(tcp_server->efd); close(tcp_server->efd);
#endif #endif /* TCP_SERVER_USE_EPOLL */
for (uint32_t i = 0; i < MAX_INCOMING_CONNECTIONS; ++i) { for (uint32_t i = 0; i < MAX_INCOMING_CONNECTIONS; ++i) {
wipe_secure_connection(&tcp_server->incoming_connection_queue[i]); wipe_secure_connection(&tcp_server->incoming_connection_queue[i]);

View File

@ -48,4 +48,4 @@ nullable(1)
void kill_tcp_server(TCP_Server *tcp_server); void kill_tcp_server(TCP_Server *tcp_server);
#endif #endif /* C_TOXCORE_TOXCORE_TCP_SERVER_H */

View File

@ -65,4 +65,4 @@ bool announce_store_data(Announcements *announce, const uint8_t *data_public_key
#define ANNOUNCE_BUCKET_PREFIX_LENGTH 5 #define ANNOUNCE_BUCKET_PREFIX_LENGTH 5
#define ANNOUNCE_BUCKETS 32 // ANNOUNCE_BUCKETS = 2 ** ANNOUNCE_BUCKET_PREFIX_LENGTH #define ANNOUNCE_BUCKETS 32 // ANNOUNCE_BUCKETS = 2 ** ANNOUNCE_BUCKET_PREFIX_LENGTH
#endif #endif /* C_TOXCORE_TOXCORE_ANNOUNCE_H */

View File

@ -28,4 +28,4 @@
//!TOKSTYLE+ //!TOKSTYLE+
#endif // C_TOXCORE_TOXCORE_ATTRIBUTES_H #endif /* C_TOXCORE_TOXCORE_ATTRIBUTES_H */

View File

@ -197,7 +197,7 @@ non_null() bool bin_pack_u64_b(Bin_Pack *bp, uint64_t val);
non_null() bool bin_pack_bin_b(Bin_Pack *bp, const uint8_t *data, uint32_t length); non_null() bool bin_pack_bin_b(Bin_Pack *bp, const uint8_t *data, uint32_t length);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_BIN_PACK_H #endif /* C_TOXCORE_TOXCORE_BIN_PACK_H */

View File

@ -119,7 +119,7 @@ non_null() bool bin_unpack_u64_b(Bin_Unpack *bu, uint64_t *val);
non_null() bool bin_unpack_bin_b(Bin_Unpack *bu, uint8_t *data, uint32_t length); non_null() bool bin_unpack_bin_b(Bin_Unpack *bu, uint8_t *data, uint32_t length);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_BIN_UNPACK_H #endif /* C_TOXCORE_TOXCORE_BIN_UNPACK_H */

View File

@ -72,9 +72,9 @@
#define STATIC_ASSERT_(cond, msg, line) typedef int static_assert_##line[(cond) ? 1 : -1] #define STATIC_ASSERT_(cond, msg, line) typedef int static_assert_##line[(cond) ? 1 : -1]
#define STATIC_ASSERT(cond, msg, line) STATIC_ASSERT_(cond, msg, line) #define STATIC_ASSERT(cond, msg, line) STATIC_ASSERT_(cond, msg, line)
#define static_assert(cond, msg) STATIC_ASSERT(cond, msg, __LINE__) #define static_assert(cond, msg) STATIC_ASSERT(cond, msg, __LINE__)
#endif // !__GNUC__ #endif /* !__GNUC__ */
#endif // !static_assert #endif /* !static_assert */
#endif // !__cplusplus #endif /* !__cplusplus */
#ifdef __GNUC__ #ifdef __GNUC__
#define GNU_PRINTF(f, a) __attribute__((__format__(__printf__, f, a))) #define GNU_PRINTF(f, a) __attribute__((__format__(__printf__, f, a)))
@ -84,4 +84,4 @@
//!TOKSTYLE+ //!TOKSTYLE+
#endif // C_TOXCORE_TOXCORE_CCOMPAT_H #endif /* C_TOXCORE_TOXCORE_CCOMPAT_H */

View File

@ -20,7 +20,7 @@
#ifndef crypto_box_MACBYTES #ifndef crypto_box_MACBYTES
#define crypto_box_MACBYTES (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES) #define crypto_box_MACBYTES (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES)
#endif #endif /* crypto_box_MACBYTES */
// Need dht because of ENC_SECRET_KEY_SIZE and ENC_PUBLIC_KEY_SIZE // Need dht because of ENC_SECRET_KEY_SIZE and ENC_PUBLIC_KEY_SIZE
#define ENC_PUBLIC_KEY_SIZE CRYPTO_PUBLIC_KEY_SIZE #define ENC_PUBLIC_KEY_SIZE CRYPTO_PUBLIC_KEY_SIZE
@ -117,7 +117,7 @@ static void crypto_free(uint8_t *ptr, size_t bytes)
free(ptr); free(ptr);
} }
#endif // !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) #endif /* !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) */
void crypto_memzero(void *data, size_t length) void crypto_memzero(void *data, size_t length)
{ {
@ -125,7 +125,7 @@ void crypto_memzero(void *data, size_t length)
memset(data, 0, length); memset(data, 0, length);
#else #else
sodium_memzero(data, length); sodium_memzero(data, length);
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
bool crypto_memlock(void *data, size_t length) bool crypto_memlock(void *data, size_t length)
@ -139,7 +139,7 @@ bool crypto_memlock(void *data, size_t length)
} }
return true; return true;
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
bool crypto_memunlock(void *data, size_t length) bool crypto_memunlock(void *data, size_t length)
@ -153,7 +153,7 @@ bool crypto_memunlock(void *data, size_t length)
} }
return true; return true;
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
bool pk_equal(const uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE], const uint8_t pk2[CRYPTO_PUBLIC_KEY_SIZE]) bool pk_equal(const uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE], const uint8_t pk2[CRYPTO_PUBLIC_KEY_SIZE])
@ -163,7 +163,7 @@ bool pk_equal(const uint8_t pk1[CRYPTO_PUBLIC_KEY_SIZE], const uint8_t pk2[CRYPT
return memcmp(pk1, pk2, CRYPTO_PUBLIC_KEY_SIZE) == 0; return memcmp(pk1, pk2, CRYPTO_PUBLIC_KEY_SIZE) == 0;
#else #else
return crypto_verify_32(pk1, pk2) == 0; return crypto_verify_32(pk1, pk2) == 0;
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
void pk_copy(uint8_t dest[CRYPTO_PUBLIC_KEY_SIZE], const uint8_t src[CRYPTO_PUBLIC_KEY_SIZE]) void pk_copy(uint8_t dest[CRYPTO_PUBLIC_KEY_SIZE], const uint8_t src[CRYPTO_PUBLIC_KEY_SIZE])
@ -178,7 +178,7 @@ bool crypto_sha512_eq(const uint8_t *cksum1, const uint8_t *cksum2)
return memcmp(cksum1, cksum2, CRYPTO_SHA512_SIZE) == 0; return memcmp(cksum1, cksum2, CRYPTO_SHA512_SIZE) == 0;
#else #else
return crypto_verify_64(cksum1, cksum2) == 0; return crypto_verify_64(cksum1, cksum2) == 0;
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
bool crypto_sha256_eq(const uint8_t *cksum1, const uint8_t *cksum2) bool crypto_sha256_eq(const uint8_t *cksum1, const uint8_t *cksum2)
@ -188,7 +188,7 @@ bool crypto_sha256_eq(const uint8_t *cksum1, const uint8_t *cksum2)
return memcmp(cksum1, cksum2, CRYPTO_SHA256_SIZE) == 0; return memcmp(cksum1, cksum2, CRYPTO_SHA256_SIZE) == 0;
#else #else
return crypto_verify_32(cksum1, cksum2) == 0; return crypto_verify_32(cksum1, cksum2) == 0;
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
uint8_t random_u08(const Random *rng) uint8_t random_u08(const Random *rng)
@ -250,7 +250,7 @@ int32_t encrypt_precompute(const uint8_t *public_key, const uint8_t *secret_key,
return 0; return 0;
#else #else
return crypto_box_beforenm(shared_key, public_key, secret_key); return crypto_box_beforenm(shared_key, public_key, secret_key);
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
int32_t encrypt_data_symmetric(const uint8_t *shared_key, const uint8_t *nonce, int32_t encrypt_data_symmetric(const uint8_t *shared_key, const uint8_t *nonce,
@ -300,7 +300,7 @@ int32_t encrypt_data_symmetric(const uint8_t *shared_key, const uint8_t *nonce,
crypto_free(temp_plain, size_temp_plain); crypto_free(temp_plain, size_temp_plain);
crypto_free(temp_encrypted, size_temp_encrypted); crypto_free(temp_encrypted, size_temp_encrypted);
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
assert(length < INT32_MAX - crypto_box_MACBYTES); assert(length < INT32_MAX - crypto_box_MACBYTES);
return (int32_t)(length + crypto_box_MACBYTES); return (int32_t)(length + crypto_box_MACBYTES);
} }
@ -350,7 +350,7 @@ int32_t decrypt_data_symmetric(const uint8_t *shared_key, const uint8_t *nonce,
crypto_free(temp_plain, size_temp_plain); crypto_free(temp_plain, size_temp_plain);
crypto_free(temp_encrypted, size_temp_encrypted); crypto_free(temp_encrypted, size_temp_encrypted);
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
assert(length > crypto_box_MACBYTES); assert(length > crypto_box_MACBYTES);
assert(length < INT32_MAX); assert(length < INT32_MAX);
return (int32_t)(length - crypto_box_MACBYTES); return (int32_t)(length - crypto_box_MACBYTES);
@ -461,7 +461,7 @@ void crypto_hmac(uint8_t auth[CRYPTO_HMAC_SIZE], const uint8_t key[CRYPTO_HMAC_K
memcpy(auth + 16, data, length < 16 ? length : 16); memcpy(auth + 16, data, length < 16 ? length : 16);
#else #else
crypto_auth(auth, data, length, key); crypto_auth(auth, data, length, key);
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
bool crypto_hmac_verify(const uint8_t auth[CRYPTO_HMAC_SIZE], const uint8_t key[CRYPTO_HMAC_KEY_SIZE], bool crypto_hmac_verify(const uint8_t auth[CRYPTO_HMAC_SIZE], const uint8_t key[CRYPTO_HMAC_KEY_SIZE],
@ -471,7 +471,7 @@ bool crypto_hmac_verify(const uint8_t auth[CRYPTO_HMAC_SIZE], const uint8_t key[
return memcmp(auth, key, 16) == 0 && memcmp(auth + 16, data, length < 16 ? length : 16) == 0; return memcmp(auth, key, 16) == 0 && memcmp(auth + 16, data, length < 16 ? length : 16) == 0;
#else #else
return crypto_auth_verify(auth, data, length, key) == 0; return crypto_auth_verify(auth, data, length, key) == 0;
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
void crypto_sha256(uint8_t *hash, const uint8_t *data, size_t length) void crypto_sha256(uint8_t *hash, const uint8_t *data, size_t length)
@ -481,7 +481,7 @@ void crypto_sha256(uint8_t *hash, const uint8_t *data, size_t length)
memcpy(hash, data, length < CRYPTO_SHA256_SIZE ? length : CRYPTO_SHA256_SIZE); memcpy(hash, data, length < CRYPTO_SHA256_SIZE ? length : CRYPTO_SHA256_SIZE);
#else #else
crypto_hash_sha256(hash, data, length); crypto_hash_sha256(hash, data, length);
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
void crypto_sha512(uint8_t *hash, const uint8_t *data, size_t length) void crypto_sha512(uint8_t *hash, const uint8_t *data, size_t length)
@ -491,7 +491,7 @@ void crypto_sha512(uint8_t *hash, const uint8_t *data, size_t length)
memcpy(hash, data, length < CRYPTO_SHA512_SIZE ? length : CRYPTO_SHA512_SIZE); memcpy(hash, data, length < CRYPTO_SHA512_SIZE ? length : CRYPTO_SHA512_SIZE);
#else #else
crypto_hash_sha512(hash, data, length); crypto_hash_sha512(hash, data, length);
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
} }
non_null() non_null()
@ -519,7 +519,7 @@ const Random *system_random(void)
if ((true)) { if ((true)) {
return nullptr; return nullptr;
} }
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
// It is safe to call this function more than once and from different // It is safe to call this function more than once and from different
// threads -- subsequent calls won't have any effects. // threads -- subsequent calls won't have any effects.
if (sodium_init() == -1) { if (sodium_init() == -1) {

View File

@ -445,7 +445,7 @@ non_null()
void new_hmac_key(const Random *rng, uint8_t key[CRYPTO_HMAC_KEY_SIZE]); void new_hmac_key(const Random *rng, uint8_t key[CRYPTO_HMAC_KEY_SIZE]);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_CRYPTO_CORE_H #endif /* C_TOXCORE_TOXCORE_CRYPTO_CORE_H */

View File

@ -76,7 +76,7 @@ non_null()
bool tox_events_add(Tox_Events *events, const Tox_Event *event); bool tox_events_add(Tox_Events *events, const Tox_Event *event);
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H #endif /* C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H */

View File

@ -119,7 +119,7 @@ nullable(1)
void kill_forwarding(Forwarding *forwarding); void kill_forwarding(Forwarding *forwarding);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif #endif /* C_TOXCORE_TOXCORE_FORWARDING_H */

View File

@ -173,4 +173,4 @@ non_null() Friend_Conn *get_conn(const Friend_Connections *fr_c, int friendcon_i
non_null() int friend_conn_get_onion_friendnum(const Friend_Conn *fc); non_null() int friend_conn_get_onion_friendnum(const Friend_Conn *fc);
non_null() const IP_Port *friend_conn_get_dht_ip_port(const Friend_Conn *fc); non_null() const IP_Port *friend_conn_get_dht_ip_port(const Friend_Conn *fc);
#endif #endif /* C_TOXCORE_TOXCORE_FRIEND_CONNECTION_H */

View File

@ -51,4 +51,4 @@ Friend_Requests *friendreq_new(void);
nullable(1) nullable(1)
void friendreq_kill(Friend_Requests *fr); void friendreq_kill(Friend_Requests *fr);
#endif #endif /* C_TOXCORE_TOXCORE_FRIEND_REQUESTS_H */

View File

@ -395,4 +395,4 @@ void do_groupchats(Group_Chats *g_c, void *userdata);
nullable(1) nullable(1)
void kill_groupchats(Group_Chats *g_c); void kill_groupchats(Group_Chats *g_c);
#endif #endif /* C_TOXCORE_TOXCORE_GROUP_H */

View File

@ -212,7 +212,7 @@ non_null()
bool gca_is_valid_announce(const GC_Announce *announce); bool gca_is_valid_announce(const GC_Announce *announce);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_GROUP_ANNOUNCE_H #endif /* C_TOXCORE_TOXCORE_GROUP_ANNOUNCE_H */

View File

@ -806,4 +806,4 @@ GC_Chat *gc_get_group_by_public_key(const GC_Session *c, const uint8_t *public_k
non_null() non_null()
int gc_add_peers_from_announces(GC_Chat *chat, const GC_Announce *announces, uint8_t gc_announces_count); int gc_add_peers_from_announces(GC_Chat *chat, const GC_Announce *announces, uint8_t gc_announces_count);
#endif // C_TOXCORE_TOXCORE_GROUP_CHATS_H #endif /* C_TOXCORE_TOXCORE_GROUP_CHATS_H */

View File

@ -411,4 +411,4 @@ int unpack_gc_saved_peers(GC_Chat *chat, const uint8_t *data, uint16_t length);
non_null(1, 2) nullable(4) non_null(1, 2) nullable(4)
int pack_gc_saved_peers(const GC_Chat *chat, uint8_t *data, uint16_t length, uint16_t *processed); int pack_gc_saved_peers(const GC_Chat *chat, uint8_t *data, uint16_t length, uint16_t *processed);
#endif // C_TOXCORE_TOXCORE_GROUP_COMMON_H #endif /* C_TOXCORE_TOXCORE_GROUP_COMMON_H */

View File

@ -188,4 +188,4 @@ void gcc_peer_cleanup(GC_Connection *gconn);
non_null() non_null()
void gcc_cleanup(const GC_Chat *chat); void gcc_cleanup(const GC_Chat *chat);
#endif // C_TOXCORE_TOXCORE_GROUP_CONNECTION_H #endif /* C_TOXCORE_TOXCORE_GROUP_CONNECTION_H */

View File

@ -291,7 +291,7 @@ non_null()
void sanctions_list_cleanup(Moderation *moderation); void sanctions_list_cleanup(Moderation *moderation);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_GROUP_MODERATION_H #endif /* C_TOXCORE_TOXCORE_GROUP_MODERATION_H */

View File

@ -19,4 +19,4 @@ int create_gca_announce_request(
const uint8_t *client_id, const uint8_t *data_public_key, uint64_t sendback_data, const uint8_t *client_id, const uint8_t *data_public_key, uint64_t sendback_data,
const uint8_t *gc_data, uint16_t gc_data_length); const uint8_t *gc_data, uint16_t gc_data_length);
#endif // C_TOXCORE_TOXCORE_GROUP_ONION_ANNOUNCE_H #endif /* C_TOXCORE_TOXCORE_GROUP_ONION_ANNOUNCE_H */

View File

@ -37,4 +37,4 @@ bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out);
non_null() non_null()
bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out); bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out);
#endif // C_TOXCORE_TOXCORE_GROUP_PACK_H #endif /* C_TOXCORE_TOXCORE_GROUP_PACK_H */

View File

@ -68,7 +68,7 @@ non_null()
bool bs_list_remove(BS_List *list, const uint8_t *data, int id); bool bs_list_remove(BS_List *list, const uint8_t *data, int id);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif #endif /* C_TOXCORE_TOXCORE_LIST_H */

View File

@ -43,7 +43,7 @@ static const char *logger_level_name(Logger_Level level)
return "<unknown>"; return "<unknown>";
} }
#endif #endif /* NDEBUG */
non_null(1, 3, 5, 6) nullable(7) non_null(1, 3, 5, 6) nullable(7)
static void logger_stderr_handler(void *context, Logger_Level level, const char *file, int line, const char *func, static void logger_stderr_handler(void *context, Logger_Level level, const char *file, int line, const char *func,
@ -54,7 +54,7 @@ static void logger_stderr_handler(void *context, Logger_Level level, const char
fprintf(stderr, "[GL] %s %s:%d(%s): %s\n", logger_level_name(level), file, line, func, message); fprintf(stderr, "[GL] %s %s:%d(%s): %s\n", logger_level_name(level), file, line, func, message);
fprintf(stderr, "Default stderr logger triggered; aborting program\n"); fprintf(stderr, "Default stderr logger triggered; aborting program\n");
abort(); abort();
#endif #endif /* NDEBUG */
} }
static const Logger logger_stderr = { static const Logger logger_stderr = {
@ -105,7 +105,7 @@ void logger_write(const Logger *log, Logger_Level level, const char *file, int l
// one too. // one too.
const char *windows_filename = strrchr(file, '\\'); const char *windows_filename = strrchr(file, '\\');
file = windows_filename != nullptr ? windows_filename + 1 : file; file = windows_filename != nullptr ? windows_filename + 1 : file;
#endif #endif /* WIN32 */
// Format message // Format message
char msg[1024]; char msg[1024];

View File

@ -19,7 +19,7 @@ extern "C" {
#ifndef MIN_LOGGER_LEVEL #ifndef MIN_LOGGER_LEVEL
#define MIN_LOGGER_LEVEL LOGGER_LEVEL_INFO #define MIN_LOGGER_LEVEL LOGGER_LEVEL_INFO
#endif #endif /* MIN_LOGGER_LEVEL */
// NOTE: Don't forget to update build system files after modifying the enum. // NOTE: Don't forget to update build system files after modifying the enum.
typedef enum Logger_Level { typedef enum Logger_Level {
@ -100,7 +100,7 @@ void logger_abort(void);
} while (0) } while (0)
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_LOGGER_H #endif /* C_TOXCORE_TOXCORE_LOGGER_H */

View File

@ -80,7 +80,7 @@ non_null(1) nullable(2) void *mem_vrealloc(const Memory *mem, void *ptr, uint32_
non_null(1) nullable(2) void mem_delete(const Memory *mem, void *ptr); non_null(1) nullable(2) void mem_delete(const Memory *mem, void *ptr);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif #endif /* C_TOXCORE_TOXCORE_MEM_H */

View File

@ -4,31 +4,31 @@
*/ */
#ifndef _XOPEN_SOURCE #ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600 #define _XOPEN_SOURCE 600
#endif #endif /* _XOPEN_SOURCE */
#if !defined(OS_WIN32) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) #if !defined(OS_WIN32) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32))
#define OS_WIN32 #define OS_WIN32
#endif #endif /* WIN32 */
#include "mono_time.h" #include "mono_time.h"
#ifdef OS_WIN32 #ifdef OS_WIN32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#endif #endif /* OS_WIN32 */
#ifdef __APPLE__ #ifdef __APPLE__
#include <mach/clock.h> #include <mach/clock.h>
#include <mach/mach.h> #include <mach/mach.h>
#endif #endif /* __APPLE__ */
#ifndef OS_WIN32 #ifndef OS_WIN32
#include <sys/time.h> #include <sys/time.h>
#endif #endif /* OS_WIN32 */
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
#include <assert.h> #include <assert.h>
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
#include <pthread.h> #include <pthread.h>
#include <time.h> #include <time.h>
@ -44,7 +44,7 @@ struct Mono_Time {
#ifndef ESP_PLATFORM #ifndef ESP_PLATFORM
/* protect `time` from concurrent access */ /* protect `time` from concurrent access */
pthread_rwlock_t *time_update_lock; pthread_rwlock_t *time_update_lock;
#endif #endif /* ESP_PLATFORM */
mono_time_current_time_cb *current_time_callback; mono_time_current_time_cb *current_time_callback;
void *user_data; void *user_data;
@ -101,13 +101,13 @@ static uint64_t current_time_monotonic_default(void *user_data)
// This assert should always fail. If it does, the fuzzing harness didn't // This assert should always fail. If it does, the fuzzing harness didn't
// override the mono time callback. // override the mono time callback.
assert(user_data == nullptr); assert(user_data == nullptr);
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
struct timespec clock_mono; struct timespec clock_mono;
clock_gettime(CLOCK_MONOTONIC, &clock_mono); clock_gettime(CLOCK_MONOTONIC, &clock_mono);
return timespec_to_u64(clock_mono); return timespec_to_u64(clock_mono);
} }
#endif // !__APPLE__ #endif /* !__APPLE__ */
#endif // !OS_WIN32 #endif /* !OS_WIN32 */
Mono_Time *mono_time_new(const Memory *mem, mono_time_current_time_cb *current_time_callback, void *user_data) Mono_Time *mono_time_new(const Memory *mem, mono_time_current_time_cb *current_time_callback, void *user_data)
@ -133,7 +133,7 @@ Mono_Time *mono_time_new(const Memory *mem, mono_time_current_time_cb *current_t
} }
mono_time->time_update_lock = rwlock; mono_time->time_update_lock = rwlock;
#endif #endif /* ESP_PLATFORM */
mono_time_set_current_time_callback(mono_time, current_time_callback, user_data); mono_time_set_current_time_callback(mono_time, current_time_callback, user_data);
@ -145,7 +145,7 @@ Mono_Time *mono_time_new(const Memory *mem, mono_time_current_time_cb *current_t
// Never return time = 0 in case time() returns 0 (e.g. on microcontrollers // Never return time = 0 in case time() returns 0 (e.g. on microcontrollers
// without battery-powered RTC or ones where NTP didn't initialise it yet). // without battery-powered RTC or ones where NTP didn't initialise it yet).
mono_time->base_time = max_u64(1, (uint64_t)time(nullptr)) * UINT64_C(1000) - current_time_monotonic(mono_time); mono_time->base_time = max_u64(1, (uint64_t)time(nullptr)) * UINT64_C(1000) - current_time_monotonic(mono_time);
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
mono_time_update(mono_time); mono_time_update(mono_time);
@ -160,7 +160,7 @@ void mono_time_free(const Memory *mem, Mono_Time *mono_time)
#ifndef ESP_PLATFORM #ifndef ESP_PLATFORM
pthread_rwlock_destroy(mono_time->time_update_lock); pthread_rwlock_destroy(mono_time->time_update_lock);
mem_delete(mem, mono_time->time_update_lock); mem_delete(mem, mono_time->time_update_lock);
#endif #endif /* ESP_PLATFORM */
mem_delete(mem, mono_time); mem_delete(mem, mono_time);
} }
@ -171,11 +171,11 @@ void mono_time_update(Mono_Time *mono_time)
#ifndef ESP_PLATFORM #ifndef ESP_PLATFORM
pthread_rwlock_wrlock(mono_time->time_update_lock); pthread_rwlock_wrlock(mono_time->time_update_lock);
#endif #endif /* ESP_PLATFORM */
mono_time->cur_time = cur_time; mono_time->cur_time = cur_time;
#ifndef ESP_PLATFORM #ifndef ESP_PLATFORM
pthread_rwlock_unlock(mono_time->time_update_lock); pthread_rwlock_unlock(mono_time->time_update_lock);
#endif #endif /* ESP_PLATFORM */
} }
uint64_t mono_time_get_ms(const Mono_Time *mono_time) uint64_t mono_time_get_ms(const Mono_Time *mono_time)
@ -183,11 +183,11 @@ uint64_t mono_time_get_ms(const Mono_Time *mono_time)
#if !defined(ESP_PLATFORM) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) #if !defined(ESP_PLATFORM) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
// Fuzzing is only single thread for now, no locking needed */ // Fuzzing is only single thread for now, no locking needed */
pthread_rwlock_rdlock(mono_time->time_update_lock); pthread_rwlock_rdlock(mono_time->time_update_lock);
#endif #endif /* !ESP_PLATFORM */
const uint64_t cur_time = mono_time->cur_time; const uint64_t cur_time = mono_time->cur_time;
#if !defined(ESP_PLATFORM) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) #if !defined(ESP_PLATFORM) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
pthread_rwlock_unlock(mono_time->time_update_lock); pthread_rwlock_unlock(mono_time->time_update_lock);
#endif #endif /* !ESP_PLATFORM */
return cur_time; return cur_time;
} }

View File

@ -100,7 +100,7 @@ void mono_time_set_current_time_callback(Mono_Time *mono_time,
mono_time_current_time_cb *current_time_callback, void *user_data); mono_time_current_time_cb *current_time_callback, void *user_data);
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_MONO_TIME_H #endif /* C_TOXCORE_TOXCORE_MONO_TIME_H */

View File

@ -3193,7 +3193,7 @@ static void kill_timedout(Net_Crypto *c, void *userdata)
/* do_timeout_here(); */ /* do_timeout_here(); */
} }
#endif #endif /* 0 */
} }
} }

View File

@ -414,4 +414,4 @@ void do_net_crypto(Net_Crypto *c, void *userdata);
nullable(1) nullable(1)
void kill_net_crypto(Net_Crypto *c); void kill_net_crypto(Net_Crypto *c);
#endif #endif /* C_TOXCORE_TOXCORE_NET_CRYPTO_H */

View File

@ -9,31 +9,31 @@
#ifdef __APPLE__ #ifdef __APPLE__
#define _DARWIN_C_SOURCE #define _DARWIN_C_SOURCE
#endif #endif /* __APPLE__ */
// For Solaris. // For Solaris.
#ifdef __sun #ifdef __sun
#define __EXTENSIONS__ 1 #define __EXTENSIONS__ 1
#endif #endif /* __sun */
// For Linux (and some BSDs). // For Linux (and some BSDs).
#ifndef _XOPEN_SOURCE #ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
#endif #endif /* _XOPEN_SOURCE */
#if defined(_WIN32) && defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WINXP #if defined(_WIN32) && defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WINXP
#undef _WIN32_WINNT #undef _WIN32_WINNT
#define _WIN32_WINNT 0x501 #define _WIN32_WINNT 0x501
#endif #endif /* defined(_WIN32) && defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WINXP */
#if !defined(OS_WIN32) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) #if !defined(OS_WIN32) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32))
#define OS_WIN32 #define OS_WIN32
#endif #endif /* !defined(OS_WIN32) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) */
#if defined(OS_WIN32) && !defined(WINVER) #if defined(OS_WIN32) && !defined(WINVER)
// Windows XP // Windows XP
#define WINVER 0x0501 #define WINVER 0x0501
#endif #endif /* defined(OS_WIN32) && !defined(WINVER) */
#include "network.h" #include "network.h"
@ -41,7 +41,7 @@
#include <u.h> // Plan 9 requires this is imported first #include <u.h> // Plan 9 requires this is imported first
// Comment line here to avoid reordering by source code formatters. // Comment line here to avoid reordering by source code formatters.
#include <libc.h> #include <libc.h>
#endif #endif /* PLAN9 */
#ifdef OS_WIN32 // Put win32 includes here #ifdef OS_WIN32 // Put win32 includes here
// The mingw32/64 Windows library warns about including winsock2.h after // The mingw32/64 Windows library warns about including winsock2.h after
@ -51,12 +51,12 @@
// Comment line here to avoid reordering by source code formatters. // Comment line here to avoid reordering by source code formatters.
#include <windows.h> #include <windows.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#endif #endif /* OS_WIN32 */
#ifdef __APPLE__ #ifdef __APPLE__
#include <mach/clock.h> #include <mach/clock.h>
#include <mach/mach.h> #include <mach/mach.h>
#endif #endif /* __APPLE__ */
#if !defined(OS_WIN32) #if !defined(OS_WIN32)
#include <arpa/inet.h> #include <arpa/inet.h>
@ -73,13 +73,13 @@
#ifdef __sun #ifdef __sun
#include <stropts.h> #include <stropts.h>
#include <sys/filio.h> #include <sys/filio.h>
#endif #endif /* __sun */
#else #else
#ifndef IPV6_V6ONLY #ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 27 #define IPV6_V6ONLY 27
#endif #endif /* IPV6_V6ONLY */
#endif #endif /* !defined(OS_WIN32) */
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
@ -95,13 +95,13 @@
// Disable MSG_NOSIGNAL on systems not supporting it, e.g. Windows, FreeBSD // Disable MSG_NOSIGNAL on systems not supporting it, e.g. Windows, FreeBSD
#if !defined(MSG_NOSIGNAL) #if !defined(MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0 #define MSG_NOSIGNAL 0
#endif #endif /* !defined(MSG_NOSIGNAL) */
#ifndef IPV6_ADD_MEMBERSHIP #ifndef IPV6_ADD_MEMBERSHIP
#ifdef IPV6_JOIN_GROUP #ifdef IPV6_JOIN_GROUP
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
#endif #endif /* IPV6_JOIN_GROUP */
#endif #endif /* IPV6_ADD_MEMBERSHIP */
static_assert(sizeof(IP4) == SIZE_IP4, "IP4 size must be 4"); static_assert(sizeof(IP4) == SIZE_IP4, "IP4 size must be 4");
@ -148,7 +148,7 @@ static int inet_pton6(const char *addr_string, struct in6_addr *addrbuf)
#else #else
#ifndef IPV6_V6ONLY #ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 27 #define IPV6_V6ONLY 27
#endif #endif /* IPV6_V6ONLY */
static bool should_ignore_recv_error(int err) static bool should_ignore_recv_error(int err)
{ {
@ -228,7 +228,7 @@ static int inet_pton6(const char *addrString, struct in6_addr *addrbuf)
return 1; return 1;
} }
#endif #endif /* !defined(OS_WIN32) */
static_assert(TOX_INET6_ADDRSTRLEN >= INET6_ADDRSTRLEN, static_assert(TOX_INET6_ADDRSTRLEN >= INET6_ADDRSTRLEN,
"TOX_INET6_ADDRSTRLEN should be greater or equal to INET6_ADDRSTRLEN (#INET6_ADDRSTRLEN)"); "TOX_INET6_ADDRSTRLEN should be greater or equal to INET6_ADDRSTRLEN (#INET6_ADDRSTRLEN)");
@ -337,7 +337,7 @@ static void fill_addr6(const IP6 *ip, struct in6_addr *addr)
#if !defined(INADDR_LOOPBACK) #if !defined(INADDR_LOOPBACK)
#define INADDR_LOOPBACK 0x7f000001 #define INADDR_LOOPBACK 0x7f000001
#endif #endif /* !defined(INADDR_LOOPBACK) */
static const IP empty_ip = {{0}}; static const IP empty_ip = {{0}};
@ -372,7 +372,7 @@ IP6 get_ip6_loopback(void)
#ifndef OS_WIN32 #ifndef OS_WIN32
#define INVALID_SOCKET (-1) #define INVALID_SOCKET (-1)
#endif #endif /* OS_WIN32 */
Socket net_invalid_socket(void) Socket net_invalid_socket(void)
{ {
@ -488,7 +488,7 @@ static int sys_close(void *obj, int sock)
return closesocket(sock); return closesocket(sock);
#else // !OS_WIN32 #else // !OS_WIN32
return close(sock); return close(sock);
#endif #endif /* OS_WIN32 */
} }
non_null() non_null()
@ -518,7 +518,7 @@ static int sys_recvbuf(void *obj, int sock)
#else #else
int count = 0; int count = 0;
ioctl(sock, FIONREAD, &count); ioctl(sock, FIONREAD, &count);
#endif #endif /* OS_WIN32 */
return count; return count;
} }
@ -603,14 +603,14 @@ const Network *system_network(void)
if ((true)) { if ((true)) {
return nullptr; return nullptr;
} }
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
#ifdef OS_WIN32 #ifdef OS_WIN32
WSADATA wsaData; WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR) { if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR) {
return nullptr; return nullptr;
} }
#endif #endif /* OS_WIN32 */
return &system_network_obj; return &system_network_obj;
} }
@ -620,9 +620,9 @@ void system_network_deinit(const Network *ns)
{ {
#ifdef OS_WIN32 #ifdef OS_WIN32
WSACleanup(); WSACleanup();
#endif #endif /* OS_WIN32 */
} }
#endif #endif /* 0 */
non_null() non_null()
static int net_setsockopt(const Network *ns, Socket sock, int level, int optname, const void *optval, size_t optlen) static int net_setsockopt(const Network *ns, Socket sock, int level, int optname, const void *optval, size_t optlen)
@ -871,7 +871,7 @@ bool set_socket_nosigpipe(const Network *ns, Socket sock)
return net_setsockopt(ns, sock, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(int)) == 0; return net_setsockopt(ns, sock, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof(int)) == 0;
#else #else
return true; return true;
#endif #endif /* __APPLE__ */
} }
bool set_socket_reuseaddr(const Network *ns, Socket sock) bool set_socket_reuseaddr(const Network *ns, Socket sock)
@ -1287,7 +1287,7 @@ Networking_Core *new_networking_ex(
} }
net_kill_strerror(strerror); net_kill_strerror(strerror);
#endif #endif /* ESP_PLATFORM */
} }
/* A hanging program or a different user might block the standard port. /* A hanging program or a different user might block the standard port.
@ -1622,7 +1622,7 @@ static int addr_resolve(const Network *ns, const char *address, IP *to, IP *extr
if ((true)) { if ((true)) {
return 0; return 0;
} }
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
if (address == nullptr || to == nullptr) { if (address == nullptr || to == nullptr) {
return 0; return 0;
@ -1750,7 +1750,7 @@ bool net_connect(const Memory *mem, const Logger *log, Socket sock, const IP_Por
if ((true)) { if ((true)) {
return true; return true;
} }
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
Ip_Ntoa ip_str; Ip_Ntoa ip_str;
LOGGER_DEBUG(log, "connecting socket %d to %s:%d", LOGGER_DEBUG(log, "connecting socket %d to %s:%d",
@ -1807,7 +1807,7 @@ int32_t net_getipport(const Memory *mem, const char *node, IP_Port **res, int to
*res = ip_port; *res = ip_port;
return 1; return 1;
} }
#endif #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
// It's not an IP address, so now we try doing a DNS lookup. // It's not an IP address, so now we try doing a DNS lookup.
struct addrinfo *infos; struct addrinfo *infos;
@ -2019,14 +2019,14 @@ bool ipv6_ipv4_in_v6(const IP6 *a)
int net_error(void) int net_error(void)
{ {
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #ifdef OS_WIN32
return WSAGetLastError(); return WSAGetLastError();
#else #else
return errno; return errno;
#endif #endif /* OS_WIN32 */
} }
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #ifdef OS_WIN32
char *net_new_strerror(int error) char *net_new_strerror(int error)
{ {
char *str = nullptr; char *str = nullptr;
@ -2066,7 +2066,7 @@ static const char *net_strerror_r(int error, char *tmp, size_t tmp_size)
return tmp; return tmp;
} }
#endif #endif /* GNU */
char *net_new_strerror(int error) char *net_new_strerror(int error)
{ {
char tmp[256]; char tmp[256];
@ -2086,13 +2086,13 @@ char *net_new_strerror(int error)
return str; return str;
} }
#endif #endif /* OS_WIN32 */
void net_kill_strerror(char *strerror) void net_kill_strerror(char *strerror)
{ {
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #ifdef OS_WIN32
LocalFree((char *)strerror); LocalFree((char *)strerror);
#else #else
free(strerror); free(strerror);
#endif #endif /* OS_WIN32 */
} }

View File

@ -564,7 +564,7 @@ nullable(1)
void kill_networking(Networking_Core *net); void kill_networking(Networking_Core *net);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif #endif /* C_TOXCORE_TOXCORE_NETWORK_H */

View File

@ -155,4 +155,4 @@ nullable(1)
void kill_onion(Onion *onion); void kill_onion(Onion *onion);
#endif #endif /* C_TOXCORE_TOXCORE_ONION_H */

View File

@ -138,4 +138,4 @@ Onion_Announce *new_onion_announce(const Logger *log, const Memory *mem, const R
nullable(1) nullable(1)
void kill_onion_announce(Onion_Announce *onion_a); void kill_onion_announce(Onion_Announce *onion_a);
#endif #endif /* C_TOXCORE_TOXCORE_ONION_ANNOUNCE_H */

View File

@ -1578,7 +1578,7 @@ int onion_delfriend(Onion_Client *onion_c, int friend_num)
dht_delfriend(onion_c->dht, onion_c->friends_list[friend_num].dht_public_key, 0); dht_delfriend(onion_c->dht, onion_c->friends_list[friend_num].dht_public_key, 0);
} }
#endif #endif /* 0 */
crypto_memzero(&onion_c->friends_list[friend_num], sizeof(Onion_Friend)); crypto_memzero(&onion_c->friends_list[friend_num], sizeof(Onion_Friend));
unsigned int i; unsigned int i;

View File

@ -237,4 +237,4 @@ non_null(1) nullable(2)
void onion_friend_set_gc_data(Onion_Friend *onion_friend, const uint8_t *gc_data, uint16_t gc_data_length); void onion_friend_set_gc_data(Onion_Friend *onion_friend, const uint8_t *gc_data, uint16_t gc_data_length);
non_null() bool onion_friend_is_groupchat(const Onion_Friend *onion_friend); non_null() bool onion_friend_is_groupchat(const Onion_Friend *onion_friend);
#endif #endif /* C_TOXCORE_TOXCORE_ONION_CLIENT_H */

View File

@ -45,4 +45,4 @@ void ping_iterate(Ping *ping);
non_null() non_null()
void ping_send_request(Ping *ping, const IP_Port *ipp, const uint8_t *public_key); void ping_send_request(Ping *ping, const IP_Port *ipp, const uint8_t *public_key);
#endif // C_TOXCORE_TOXCORE_PING_H #endif /* C_TOXCORE_TOXCORE_PING_H */

View File

@ -60,7 +60,7 @@ int32_t ping_array_check(Ping_Array *array, const Mono_Time *mono_time, uint8_t
uint64_t ping_id); uint64_t ping_id);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_PING_ARRAY_H #endif /* C_TOXCORE_TOXCORE_PING_ARRAY_H */

View File

@ -51,4 +51,4 @@ void shared_key_cache_free(Shared_Key_Cache *cache);
non_null() non_null()
const uint8_t* shared_key_cache_lookup(Shared_Key_Cache *cache, const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]); const uint8_t* shared_key_cache_lookup(Shared_Key_Cache *cache, const uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]);
#endif // C_TOXCORE_TOXCORE_SHARED_KEY_CACHE_H #endif /* C_TOXCORE_TOXCORE_SHARED_KEY_CACHE_H */

View File

@ -86,7 +86,7 @@ uint16_t lendian_to_host16(uint16_t lendian)
return (lendian << 8) | (lendian >> 8); return (lendian << 8) | (lendian >> 8);
#else #else
return lendian; return lendian;
#endif #endif /* WORDS_BIGENDIAN */
} }
uint16_t host_to_lendian16(uint16_t host) uint16_t host_to_lendian16(uint16_t host)
@ -100,7 +100,7 @@ void host_to_lendian_bytes64(uint8_t *dest, uint64_t num)
num = ((num << 8) & 0xFF00FF00FF00FF00) | ((num >> 8) & 0xFF00FF00FF00FF); num = ((num << 8) & 0xFF00FF00FF00FF00) | ((num >> 8) & 0xFF00FF00FF00FF);
num = ((num << 16) & 0xFFFF0000FFFF0000) | ((num >> 16) & 0xFFFF0000FFFF); num = ((num << 16) & 0xFFFF0000FFFF0000) | ((num >> 16) & 0xFFFF0000FFFF);
num = (num << 32) | (num >> 32); num = (num << 32) | (num >> 32);
#endif #endif /* WORDS_BIGENDIAN */
memcpy(dest, &num, sizeof(uint64_t)); memcpy(dest, &num, sizeof(uint64_t));
} }
@ -112,7 +112,7 @@ void lendian_bytes_to_host64(uint64_t *dest, const uint8_t *lendian)
d = ((d << 8) & 0xFF00FF00FF00FF00) | ((d >> 8) & 0xFF00FF00FF00FF); d = ((d << 8) & 0xFF00FF00FF00FF00) | ((d >> 8) & 0xFF00FF00FF00FF);
d = ((d << 16) & 0xFFFF0000FFFF0000) | ((d >> 16) & 0xFFFF0000FFFF); d = ((d << 16) & 0xFFFF0000FFFF0000) | ((d >> 16) & 0xFFFF0000FFFF);
d = (d << 32) | (d >> 32); d = (d << 32) | (d >> 32);
#endif #endif /* WORDS_BIGENDIAN */
*dest = d; *dest = d;
} }
@ -121,7 +121,7 @@ void host_to_lendian_bytes32(uint8_t *dest, uint32_t num)
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
num = ((num << 8) & 0xFF00FF00) | ((num >> 8) & 0xFF00FF); num = ((num << 8) & 0xFF00FF00) | ((num >> 8) & 0xFF00FF);
num = (num << 16) | (num >> 16); num = (num << 16) | (num >> 16);
#endif #endif /* WORDS_BIGENDIAN */
memcpy(dest, &num, sizeof(uint32_t)); memcpy(dest, &num, sizeof(uint32_t));
} }
@ -132,7 +132,7 @@ void lendian_bytes_to_host32(uint32_t *dest, const uint8_t *lendian)
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
d = ((d << 8) & 0xFF00FF00) | ((d >> 8) & 0xFF00FF); d = ((d << 8) & 0xFF00FF00) | ((d >> 8) & 0xFF00FF);
d = (d << 16) | (d >> 16); d = (d << 16) | (d >> 16);
#endif #endif /* WORDS_BIGENDIAN */
*dest = d; *dest = d;
} }
@ -140,7 +140,7 @@ void host_to_lendian_bytes16(uint8_t *dest, uint16_t num)
{ {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
num = (num << 8) | (num >> 8); num = (num << 8) | (num >> 8);
#endif #endif /* WORDS_BIGENDIAN */
memcpy(dest, &num, sizeof(uint16_t)); memcpy(dest, &num, sizeof(uint16_t));
} }
@ -150,6 +150,6 @@ void lendian_bytes_to_host16(uint16_t *dest, const uint8_t *lendian)
memcpy(&d, lendian, sizeof(uint16_t)); memcpy(&d, lendian, sizeof(uint16_t));
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
d = (d << 8) | (d >> 8); d = (d << 8) | (d >> 8);
#endif #endif /* WORDS_BIGENDIAN */
*dest = d; *dest = d;
} }

View File

@ -82,7 +82,7 @@ non_null()
void lendian_bytes_to_host16(uint16_t *dest, const uint8_t *lendian); void lendian_bytes_to_host16(uint16_t *dest, const uint8_t *lendian);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_STATE_H #endif /* C_TOXCORE_TOXCORE_STATE_H */

View File

@ -32,4 +32,4 @@ void generate_timed_auth(const Mono_Time *mono_time, uint16_t timeout, const uin
non_null(1, 3, 6) nullable(4) non_null(1, 3, 6) nullable(4)
bool check_timed_auth(const Mono_Time *mono_time, uint16_t timeout, const uint8_t *key, bool check_timed_auth(const Mono_Time *mono_time, uint16_t timeout, const uint8_t *key,
const uint8_t *data, uint16_t length, const uint8_t *timed_auth); const uint8_t *data, uint16_t length, const uint8_t *timed_auth);
#endif #endif /* C_TOXCORE_TOXCORE_TIMED_AUTH_H */

View File

@ -8,7 +8,7 @@
*/ */
#ifndef _XOPEN_SOURCE #ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600 #define _XOPEN_SOURCE 600
#endif #endif /* _XOPEN_SOURCE */
#include "tox.h" #include "tox.h"

View File

@ -5731,7 +5731,7 @@ void tox_callback_group_moderation(Tox *tox, tox_group_moderation_cb *callback);
/** @} */ /** @} */
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
//!TOKSTYLE- //!TOKSTYLE-
@ -5780,4 +5780,4 @@ typedef enum Tox_File_Kind TOX_FILE_KIND;
#endif #endif
//!TOKSTYLE+ //!TOKSTYLE+
#endif // C_TOXCORE_TOXCORE_TOX_H #endif /* C_TOXCORE_TOXCORE_TOX_H */

View File

@ -214,7 +214,7 @@ void tox_events_callback_dht_get_nodes_response(
Tox_Dispatch *dispatch, tox_events_dht_get_nodes_response_cb *callback); Tox_Dispatch *dispatch, tox_events_dht_get_nodes_response_cb *callback);
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_TOX_DISPATCH_H #endif /* C_TOXCORE_TOXCORE_TOX_DISPATCH_H */

View File

@ -254,7 +254,7 @@ non_null() bool tox_event_group_moderation_unpack(Tox_Event_Group_Moderation **e
non_null() bool tox_event_dht_get_nodes_response_unpack(Tox_Event_Dht_Get_Nodes_Response **event, Bin_Unpack *bu, const Memory *mem); non_null() bool tox_event_dht_get_nodes_response_unpack(Tox_Event_Dht_Get_Nodes_Response **event, Bin_Unpack *bu, const Memory *mem);
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_TOX_EVENT_H #endif /* C_TOXCORE_TOXCORE_TOX_EVENT_H */

View File

@ -109,9 +109,9 @@ Tox_Events *tox_events_iterate(Tox *tox, bool fail_hard, Tox_Err_Events_Iterate
} }
non_null() non_null()
static bool tox_event_pack_handler(const void *obj, uint32_t index, const Logger *logger, Bin_Pack *bp) static bool tox_event_pack_handler(const void *arr, uint32_t index, const Logger *logger, Bin_Pack *bp)
{ {
const Tox_Event *events = (const Tox_Event *)obj; const Tox_Event *events = (const Tox_Event *)arr;
assert(events != nullptr); assert(events != nullptr);
return tox_event_pack(&events[index], bp); return tox_event_pack(&events[index], bp);
} }

View File

@ -573,7 +573,7 @@ Tox_Events *tox_events_load(const Tox_System *sys, const uint8_t *bytes, uint32_
bool tox_events_equal(const Tox_System *sys, const Tox_Events *a, const Tox_Events *b); bool tox_events_equal(const Tox_System *sys, const Tox_Events *a, const Tox_Events *b);
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_TOX_EVENTS_H #endif /* C_TOXCORE_TOXCORE_TOX_EVENTS_H */

View File

@ -21,4 +21,4 @@ non_null() bool tox_group_join_fail_pack(Tox_Group_Join_Fail val, Bin_Pack *bp);
non_null() bool tox_group_mod_event_pack(Tox_Group_Mod_Event val, Bin_Pack *bp); non_null() bool tox_group_mod_event_pack(Tox_Group_Mod_Event val, Bin_Pack *bp);
non_null() bool tox_group_exit_type_pack(Tox_Group_Exit_Type val, Bin_Pack *bp); non_null() bool tox_group_exit_type_pack(Tox_Group_Exit_Type val, Bin_Pack *bp);
#endif // C_TOXCORE_TOXCORE_TOX_PACK_H #endif /* C_TOXCORE_TOXCORE_TOX_PACK_H */

View File

@ -204,7 +204,7 @@ bool tox_group_peer_get_ip_address(const Tox *tox, uint32_t group_number, uint32
Tox_Err_Group_Peer_Query *error); Tox_Err_Group_Peer_Query *error);
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_TOX_PRIVATE_H #endif /* C_TOXCORE_TOXCORE_TOX_PRIVATE_H */

View File

@ -67,7 +67,7 @@ struct Tox {
}; };
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_TOX_STRUCT_H #endif /* C_TOXCORE_TOXCORE_TOX_STRUCT_H */

View File

@ -21,4 +21,4 @@ non_null() bool tox_group_join_fail_unpack(Tox_Group_Join_Fail *val, Bin_Unpack
non_null() bool tox_group_mod_event_unpack(Tox_Group_Mod_Event *val, Bin_Unpack *bu); non_null() bool tox_group_mod_event_unpack(Tox_Group_Mod_Event *val, Bin_Unpack *bu);
non_null() bool tox_group_exit_type_unpack(Tox_Group_Exit_Type *val, Bin_Unpack *bu); non_null() bool tox_group_exit_type_unpack(Tox_Group_Exit_Type *val, Bin_Unpack *bu);
#endif // C_TOXCORE_TOXCORE_TOX_UNPACK_H #endif /* C_TOXCORE_TOXCORE_TOX_UNPACK_H */

View File

@ -9,7 +9,7 @@
*/ */
#ifndef _XOPEN_SOURCE #ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600 #define _XOPEN_SOURCE 600
#endif #endif /* _XOPEN_SOURCE */
#include "util.h" #include "util.h"

View File

@ -84,7 +84,7 @@ non_null()
uint16_t data_checksum(const uint8_t *data, uint32_t length); uint16_t data_checksum(const uint8_t *data, uint32_t length);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } /* extern "C" */
#endif #endif
#endif // C_TOXCORE_TOXCORE_UTIL_H #endif /* C_TOXCORE_TOXCORE_UTIL_H */

View File

@ -9,4 +9,4 @@
#define TOX_ENC_SAVE_MAGIC_NUMBER ((const uint8_t *)"toxEsave") #define TOX_ENC_SAVE_MAGIC_NUMBER ((const uint8_t *)"toxEsave")
#define TOX_ENC_SAVE_MAGIC_LENGTH 8 #define TOX_ENC_SAVE_MAGIC_LENGTH 8
#endif #endif /* C_TOXCORE_TOXENCRYPTSAVE_DEFINES_H */

View File

@ -362,7 +362,7 @@ bool tox_is_data_encrypted(const uint8_t data[TOX_PASS_ENCRYPTION_EXTRA_LENGTH])
#ifdef __cplusplus #ifdef __cplusplus
} } /* extern "C" */
#endif #endif
//!TOKSTYLE- //!TOKSTYLE-
@ -374,4 +374,4 @@ typedef Tox_Err_Get_Salt TOX_ERR_GET_SALT;
//!TOKSTYLE+ //!TOKSTYLE+
#endif // C_TOXCORE_TOXENCRYPTSAVE_TOXENCRYPTSAVE_H #endif /* C_TOXCORE_TOXENCRYPTSAVE_TOXENCRYPTSAVE_H */