diff --git a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 index a316ea13..2b644300 100644 --- a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 +++ b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 @@ -1 +1 @@ -3acc3a1f08e67dac66d91657a36d98be397fa3f14bc4798d3349605e37a90fc3 /usr/local/bin/tox-bootstrapd +09cd2be2005d21ad9f146a59d4f7d7b2221a07d7b6e72a63387dc468ea477a1d /usr/local/bin/tox-bootstrapd diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index ac19a6df..41ba8338 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -4,6 +4,7 @@ CIMPLE_FILES = [ "//c-toxcore/toxav:cimple_files", "//c-toxcore/toxcore:cimple_files", "//c-toxcore/toxencryptsave:cimple_files", + "//c-toxcore/third_party:cimple_files", ] sh_test( @@ -40,7 +41,6 @@ sh_test( "-RTS", ], data = CIMPLE_FILES + [ - "//c-toxcore/third_party:headers", "//hs-tokstyle:headers", "@libsodium//:headers", "@libvpx//:headers", diff --git a/testing/misc_tools.h b/testing/misc_tools.h index 3e5627d5..65bdc9fd 100644 --- a/testing/misc_tools.h +++ b/testing/misc_tools.h @@ -21,7 +21,7 @@ int cmdline_parsefor_ipv46(int argc, char **argv, bool *ipv6enabled); int use_test_rng(uint32_t seed); #ifdef __cplusplus -} +} /* extern "C" */ #endif #endif diff --git a/third_party/BUILD.bazel b/third_party/BUILD.bazel index 45344cb2..528558fb 100644 --- a/third_party/BUILD.bazel +++ b/third_party/BUILD.bazel @@ -9,7 +9,10 @@ cc_library( ) filegroup( - name = "headers", - srcs = ["cmp/cmp.h"], + name = "cimple_files", + srcs = [ + "cmp/cmp.c", + "cmp/cmp.h", + ], visibility = ["//c-toxcore:__subpackages__"], ) diff --git a/third_party/cmp b/third_party/cmp index e8367032..065b1cae 160000 --- a/third_party/cmp +++ b/third_party/cmp @@ -1 +1 @@ -Subproject commit e836703291392aba9db92b46fb47929521fac71f +Subproject commit 065b1caed4bee66ef5f87f5ac3a9ee7a78f72386 diff --git a/toxav/audio.h b/toxav/audio.h index 1a229d72..3ae42511 100644 --- a/toxav/audio.h +++ b/toxav/audio.h @@ -70,4 +70,4 @@ void ac_iterate(ACSession *ac); 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); -#endif // C_TOXCORE_TOXAV_AUDIO_H +#endif /* C_TOXCORE_TOXAV_AUDIO_H */ diff --git a/toxav/bwcontroller.h b/toxav/bwcontroller.h index 98c47e0a..53931c03 100644 --- a/toxav/bwcontroller.h +++ b/toxav/bwcontroller.h @@ -20,4 +20,4 @@ void bwc_kill(BWController *bwc); void bwc_add_lost(BWController *bwc, uint32_t bytes_lost); void bwc_add_recv(BWController *bwc, uint32_t recv_bytes); -#endif // C_TOXCORE_TOXAV_BWCONTROLLER_H +#endif /* C_TOXCORE_TOXAV_BWCONTROLLER_H */ diff --git a/toxav/groupav.h b/toxav/groupav.h index eef06c9d..ee76d494 100644 --- a/toxav/groupav.h +++ b/toxav/groupav.h @@ -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. */ 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 */ diff --git a/toxav/msi.h b/toxav/msi.h index daff2d8a..316a3ef1 100644 --- a/toxav/msi.h +++ b/toxav/msi.h @@ -144,4 +144,4 @@ int msi_answer(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 */ diff --git a/toxav/ring_buffer.h b/toxav/ring_buffer.h index 775bf503..d89e25e2 100644 --- a/toxav/ring_buffer.h +++ b/toxav/ring_buffer.h @@ -25,7 +25,7 @@ uint16_t rb_size(const RingBuffer *b); uint16_t rb_data(const RingBuffer *b, void **dest); #ifdef __cplusplus -} +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXAV_RING_BUFFER_H +#endif /* C_TOXCORE_TOXAV_RING_BUFFER_H */ diff --git a/toxav/rtp.h b/toxav/rtp.h index 6144c639..c55c080b 100644 --- a/toxav/rtp.h +++ b/toxav/rtp.h @@ -204,7 +204,7 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint32_t length, bool is_keyframe, const Logger *log); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXAV_RTP_H +#endif /* C_TOXCORE_TOXAV_RTP_H */ diff --git a/toxav/toxav.h b/toxav/toxav.h index ff65c3fa..5ed674ab 100644 --- a/toxav/toxav.h +++ b/toxav/toxav.h @@ -846,7 +846,7 @@ bool toxav_groupchat_av_enabled(Tox *tox, uint32_t groupnumber); /** @} */ #ifdef __cplusplus -} +} /* extern "C" */ #endif //!TOKSTYLE- @@ -865,4 +865,4 @@ typedef enum Toxav_Friend_Call_State TOXAV_FRIEND_CALL_STATE; #endif //!TOKSTYLE+ -#endif // C_TOXCORE_TOXAV_TOXAV_H +#endif /* C_TOXCORE_TOXAV_TOXAV_H */ diff --git a/toxav/video.c b/toxav/video.c index 338d0f04..301400b0 100644 --- a/toxav/video.c +++ b/toxav/video.c @@ -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_optimal_sz = 600; cfg->rc_buf_sz = 1000; -#endif +#endif /* 0 */ } 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; } -#endif +#endif /* 0 */ vc->linfts = current_time_monotonic(mono_time); vc->lcfd = 60; vc->vcb = cb; diff --git a/toxav/video.h b/toxav/video.h index 22ef9599..57db74ac 100644 --- a/toxav/video.h +++ b/toxav/video.h @@ -51,4 +51,4 @@ void vc_iterate(VCSession *vc); 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); -#endif // C_TOXCORE_TOXAV_VIDEO_H +#endif /* C_TOXCORE_TOXAV_VIDEO_H */ diff --git a/toxcore/DHT.c b/toxcore/DHT.c index e4bc1f1c..12738f3d 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c @@ -585,7 +585,7 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed #ifndef NDEBUG const uint32_t increment = ipp_size + CRYPTO_PUBLIC_KEY_SIZE; assert(increment == PACKED_NODE_SIZE_IP4 || increment == PACKED_NODE_SIZE_IP6); -#endif +#endif /* NDEBUG */ } if (processed_data_len != nullptr) { @@ -829,7 +829,7 @@ static void get_close_nodes_inner( continue; } -#endif +#endif /* CHECK_ANNOUNCE_NODE */ if (num_nodes < MAX_SENT_NODES) { 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; } -#endif +#endif /* CHECK_ANNOUNCE_NODE */ /** @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 client->announce_node = false; send_announce_ping(dht, public_key, ip_port); -#endif +#endif /* CHECK_ANNOUNCE_NODE */ return true; } @@ -2691,7 +2691,7 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw #ifdef CHECK_ANNOUNCE_NODE 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); diff --git a/toxcore/DHT.h b/toxcore/DHT.h index 2203a492..c23483b5 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h @@ -169,7 +169,7 @@ typedef struct Client_data { #ifdef CHECK_ANNOUNCE_NODE /* Responded to data search? */ bool announce_node; -#endif +#endif /* CHECK_ANNOUNCE_NODE */ } 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. */ non_null() 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 @@ -558,7 +558,7 @@ non_null() unsigned int ipport_self_copy(const DHT *dht, IP_Port *dest); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif +#endif /* C_TOXCORE_TOXCORE_DHT_H */ diff --git a/toxcore/LAN_discovery.c b/toxcore/LAN_discovery.c index ce34551d..e86b16fc 100644 --- a/toxcore/LAN_discovery.c +++ b/toxcore/LAN_discovery.c @@ -21,7 +21,7 @@ #include #include -#endif +#endif /* WIN32 */ #if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) #include @@ -29,15 +29,15 @@ #include #include #include -#endif +#endif /* Linux/BSD */ #ifdef __linux__ #include -#endif +#endif /* Linux */ #if defined(__FreeBSD__) || defined(__DragonFly__) #include -#endif +#endif /* BSD */ #include "ccompat.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)); } -#endif +#endif /* platforms */ /** @brief Send packet to all IPv4 broadcast addresses * diff --git a/toxcore/LAN_discovery.h b/toxcore/LAN_discovery.h index 5d9c8333..0c921fe9 100644 --- a/toxcore/LAN_discovery.h +++ b/toxcore/LAN_discovery.h @@ -53,4 +53,4 @@ bool ip_is_local(const IP *ip); non_null() bool ip_is_lan(const IP *ip); -#endif // C_TOXCORE_TOXCORE_LAN_DISCOVERY_H +#endif /* C_TOXCORE_TOXCORE_LAN_DISCOVERY_H */ diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 7195dc7b..c54fdcdf 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -2213,7 +2213,7 @@ static int m_handle_packet_file_sendrequest(Messenger *m, const int friendcon_id return 0; } -#endif +#endif /* UINT8_MAX >= MAX_CONCURRENT_FILE_PIPES */ uint64_t filesize; uint32_t file_type; @@ -2281,7 +2281,7 @@ static int m_handle_packet_file_control(Messenger *m, const int friendcon_id, co 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) { // 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; } -#endif +#endif /* UINT8_MAX >= MAX_CONCURRENT_FILE_PIPES */ 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()); #ifdef __LP64__ assert(memcmp(cur_data, &temp, friend_size()) == 0); -#endif +#endif /* __LP64__ */ cur_data = next_data; ++num; } diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 4e9766cb..5b52dedc 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -41,7 +41,7 @@ typedef enum Message_Type { #ifndef MESSENGER_DEFINED #define MESSENGER_DEFINED typedef struct Messenger Messenger; -#endif // MESSENGER_DEFINED +#endif /* MESSENGER_DEFINED */ // Returns the size of the data 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() bool m_is_receiving_file(Messenger *m); -#endif +#endif /* C_TOXCORE_TOXCORE_MESSENGER_H */ diff --git a/toxcore/TCP_client.h b/toxcore/TCP_client.h index eceed047..7210afd7 100644 --- a/toxcore/TCP_client.h +++ b/toxcore/TCP_client.h @@ -151,4 +151,4 @@ non_null() 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 */ diff --git a/toxcore/TCP_common.h b/toxcore/TCP_common.h index 778962f8..c17e6c0b 100644 --- a/toxcore/TCP_common.h +++ b/toxcore/TCP_common.h @@ -111,4 +111,4 @@ int read_packet_tcp_secure_connection( const uint8_t *shared_key, uint8_t *recv_nonce, uint8_t *data, uint16_t max_len, const IP_Port *ip_port); -#endif +#endif /* C_TOXCORE_TOXCORE_TCP_COMMON_H */ diff --git a/toxcore/TCP_connection.h b/toxcore/TCP_connection.h index 403083f2..af93fb42 100644 --- a/toxcore/TCP_connection.h +++ b/toxcore/TCP_connection.h @@ -310,4 +310,4 @@ void do_tcp_connections(const Logger *logger, TCP_Connections *tcp_c, void *user nullable(1) void kill_tcp_connections(TCP_Connections *tcp_c); -#endif +#endif /* C_TOXCORE_TOXCORE_TCP_CONNECTION_H */ diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index 1a3c7aff..d8e0e783 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c @@ -11,12 +11,12 @@ #include #if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32) #include -#endif +#endif /* !WIN32 */ #ifdef TCP_SERVER_USE_EPOLL #include #include -#endif +#endif /* TCP_SERVER_USE_EPOLL */ #include "DHT.h" #include "TCP_common.h" @@ -35,7 +35,7 @@ #define TCP_SOCKET_INCOMING 1 #define TCP_SOCKET_UNCONFIRMED 2 #define TCP_SOCKET_CONFIRMED 3 -#endif +#endif /* TCP_SERVER_USE_EPOLL */ typedef struct TCP_Secure_Conn { uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; @@ -72,7 +72,7 @@ struct TCP_Server { #ifdef TCP_SERVER_USE_EPOLL int efd; uint64_t last_run_pinged; -#endif +#endif /* TCP_SERVER_USE_EPOLL */ Socket *socks_listening; 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 #ifndef EPOLLRDHUP #define EPOLLRDHUP 0x2000 -#endif -#endif +#endif /* EPOLLRDHUP */ +#endif /* TCP_SERVER_USE_EPOLL */ /** @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; } -#endif +#endif /* TCP_SERVER_USE_EPOLL */ 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; } -#endif +#endif /* TCP_SERVER_USE_EPOLL */ temp->socks_listening[temp->num_listening_socks] = sock; ++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() 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); } } -#endif +#endif /* TCP_SERVER_USE_EPOLL */ non_null() 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); -#endif +#endif /* TCP_SERVER_USE_EPOLL */ for (uint32_t i = 0; i < tcp_server->size_accepted_connections; ++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); -#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; } } -#endif +#endif /* TCP_SERVER_USE_EPOLL */ 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_incoming(tcp_server); do_tcp_unconfirmed(tcp_server, mono_time); -#endif +#endif /* TCP_SERVER_USE_EPOLL */ do_tcp_confirmed(tcp_server, mono_time); } @@ -1407,7 +1407,7 @@ void kill_tcp_server(TCP_Server *tcp_server) #ifdef TCP_SERVER_USE_EPOLL close(tcp_server->efd); -#endif +#endif /* TCP_SERVER_USE_EPOLL */ for (uint32_t i = 0; i < MAX_INCOMING_CONNECTIONS; ++i) { wipe_secure_connection(&tcp_server->incoming_connection_queue[i]); diff --git a/toxcore/TCP_server.h b/toxcore/TCP_server.h index 0349f60b..3279b016 100644 --- a/toxcore/TCP_server.h +++ b/toxcore/TCP_server.h @@ -48,4 +48,4 @@ nullable(1) void kill_tcp_server(TCP_Server *tcp_server); -#endif +#endif /* C_TOXCORE_TOXCORE_TCP_SERVER_H */ diff --git a/toxcore/announce.h b/toxcore/announce.h index bbd7a72b..a47bd0df 100644 --- a/toxcore/announce.h +++ b/toxcore/announce.h @@ -65,4 +65,4 @@ bool announce_store_data(Announcements *announce, const uint8_t *data_public_key #define ANNOUNCE_BUCKET_PREFIX_LENGTH 5 #define ANNOUNCE_BUCKETS 32 // ANNOUNCE_BUCKETS = 2 ** ANNOUNCE_BUCKET_PREFIX_LENGTH -#endif +#endif /* C_TOXCORE_TOXCORE_ANNOUNCE_H */ diff --git a/toxcore/attributes.h b/toxcore/attributes.h index 3d3aeda0..f37b5ce5 100644 --- a/toxcore/attributes.h +++ b/toxcore/attributes.h @@ -28,4 +28,4 @@ //!TOKSTYLE+ -#endif // C_TOXCORE_TOXCORE_ATTRIBUTES_H +#endif /* C_TOXCORE_TOXCORE_ATTRIBUTES_H */ diff --git a/toxcore/bin_pack.h b/toxcore/bin_pack.h index d6ada196..ce6926a4 100644 --- a/toxcore/bin_pack.h +++ b/toxcore/bin_pack.h @@ -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); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_BIN_PACK_H +#endif /* C_TOXCORE_TOXCORE_BIN_PACK_H */ diff --git a/toxcore/bin_unpack.h b/toxcore/bin_unpack.h index b5ae4ece..0554bd1a 100644 --- a/toxcore/bin_unpack.h +++ b/toxcore/bin_unpack.h @@ -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); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_BIN_UNPACK_H +#endif /* C_TOXCORE_TOXCORE_BIN_UNPACK_H */ diff --git a/toxcore/ccompat.h b/toxcore/ccompat.h index 9ea6739a..c083e4b5 100644 --- a/toxcore/ccompat.h +++ b/toxcore/ccompat.h @@ -72,9 +72,9 @@ #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) STATIC_ASSERT(cond, msg, __LINE__) -#endif // !__GNUC__ -#endif // !static_assert -#endif // !__cplusplus +#endif /* !__GNUC__ */ +#endif /* !static_assert */ +#endif /* !__cplusplus */ #ifdef __GNUC__ #define GNU_PRINTF(f, a) __attribute__((__format__(__printf__, f, a))) @@ -84,4 +84,4 @@ //!TOKSTYLE+ -#endif // C_TOXCORE_TOXCORE_CCOMPAT_H +#endif /* C_TOXCORE_TOXCORE_CCOMPAT_H */ diff --git a/toxcore/crypto_core.c b/toxcore/crypto_core.c index 1f9fde72..cfe6d3e5 100644 --- a/toxcore/crypto_core.c +++ b/toxcore/crypto_core.c @@ -20,7 +20,7 @@ #ifndef crypto_box_MACBYTES #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 #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); } -#endif // !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) +#endif /* !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) */ void crypto_memzero(void *data, size_t length) { @@ -125,7 +125,7 @@ void crypto_memzero(void *data, size_t length) memset(data, 0, length); #else sodium_memzero(data, length); -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ } bool crypto_memlock(void *data, size_t length) @@ -139,7 +139,7 @@ bool crypto_memlock(void *data, size_t length) } return true; -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ } bool crypto_memunlock(void *data, size_t length) @@ -153,7 +153,7 @@ bool crypto_memunlock(void *data, size_t length) } 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]) @@ -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; #else 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]) @@ -178,7 +178,7 @@ bool crypto_sha512_eq(const uint8_t *cksum1, const uint8_t *cksum2) return memcmp(cksum1, cksum2, CRYPTO_SHA512_SIZE) == 0; #else 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) @@ -188,7 +188,7 @@ bool crypto_sha256_eq(const uint8_t *cksum1, const uint8_t *cksum2) return memcmp(cksum1, cksum2, CRYPTO_SHA256_SIZE) == 0; #else return crypto_verify_32(cksum1, cksum2) == 0; -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ } 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; #else 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, @@ -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_encrypted, size_temp_encrypted); -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ assert(length < INT32_MAX - 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_encrypted, size_temp_encrypted); -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ assert(length > crypto_box_MACBYTES); assert(length < INT32_MAX); 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); #else 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], @@ -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; #else 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) @@ -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); #else 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) @@ -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); #else crypto_hash_sha512(hash, data, length); -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ } non_null() @@ -519,7 +519,7 @@ const Random *system_random(void) if ((true)) { return nullptr; } -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ // It is safe to call this function more than once and from different // threads -- subsequent calls won't have any effects. if (sodium_init() == -1) { diff --git a/toxcore/crypto_core.h b/toxcore/crypto_core.h index bfcddc31..f46144ce 100644 --- a/toxcore/crypto_core.h +++ b/toxcore/crypto_core.h @@ -445,7 +445,7 @@ non_null() void new_hmac_key(const Random *rng, uint8_t key[CRYPTO_HMAC_KEY_SIZE]); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_CRYPTO_CORE_H +#endif /* C_TOXCORE_TOXCORE_CRYPTO_CORE_H */ diff --git a/toxcore/events/events_alloc.h b/toxcore/events/events_alloc.h index 16d1a922..b32c9aae 100644 --- a/toxcore/events/events_alloc.h +++ b/toxcore/events/events_alloc.h @@ -76,7 +76,7 @@ non_null() bool tox_events_add(Tox_Events *events, const Tox_Event *event); #ifdef __cplusplus -} +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H +#endif /* C_TOXCORE_TOXCORE_EVENTS_EVENTS_ALLOC_H */ diff --git a/toxcore/forwarding.h b/toxcore/forwarding.h index a97971e6..cf063ba2 100644 --- a/toxcore/forwarding.h +++ b/toxcore/forwarding.h @@ -119,7 +119,7 @@ nullable(1) void kill_forwarding(Forwarding *forwarding); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif +#endif /* C_TOXCORE_TOXCORE_FORWARDING_H */ diff --git a/toxcore/friend_connection.h b/toxcore/friend_connection.h index 8f7c36e0..03bb5634 100644 --- a/toxcore/friend_connection.h +++ b/toxcore/friend_connection.h @@ -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() const IP_Port *friend_conn_get_dht_ip_port(const Friend_Conn *fc); -#endif +#endif /* C_TOXCORE_TOXCORE_FRIEND_CONNECTION_H */ diff --git a/toxcore/friend_requests.h b/toxcore/friend_requests.h index fe02682a..433d8fb9 100644 --- a/toxcore/friend_requests.h +++ b/toxcore/friend_requests.h @@ -51,4 +51,4 @@ Friend_Requests *friendreq_new(void); nullable(1) void friendreq_kill(Friend_Requests *fr); -#endif +#endif /* C_TOXCORE_TOXCORE_FRIEND_REQUESTS_H */ diff --git a/toxcore/group.h b/toxcore/group.h index e6f6c447..34ec6016 100644 --- a/toxcore/group.h +++ b/toxcore/group.h @@ -395,4 +395,4 @@ void do_groupchats(Group_Chats *g_c, void *userdata); nullable(1) void kill_groupchats(Group_Chats *g_c); -#endif +#endif /* C_TOXCORE_TOXCORE_GROUP_H */ diff --git a/toxcore/group_announce.h b/toxcore/group_announce.h index 19ca2985..0fc00976 100644 --- a/toxcore/group_announce.h +++ b/toxcore/group_announce.h @@ -212,7 +212,7 @@ non_null() bool gca_is_valid_announce(const GC_Announce *announce); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_GROUP_ANNOUNCE_H +#endif /* C_TOXCORE_TOXCORE_GROUP_ANNOUNCE_H */ diff --git a/toxcore/group_chats.h b/toxcore/group_chats.h index 57ebe60b..678221ac 100644 --- a/toxcore/group_chats.h +++ b/toxcore/group_chats.h @@ -806,4 +806,4 @@ GC_Chat *gc_get_group_by_public_key(const GC_Session *c, const uint8_t *public_k non_null() 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 */ diff --git a/toxcore/group_common.h b/toxcore/group_common.h index 6350729f..dbbd7441 100644 --- a/toxcore/group_common.h +++ b/toxcore/group_common.h @@ -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) 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 */ diff --git a/toxcore/group_connection.h b/toxcore/group_connection.h index fa7a3c94..ec78f9dd 100644 --- a/toxcore/group_connection.h +++ b/toxcore/group_connection.h @@ -188,4 +188,4 @@ void gcc_peer_cleanup(GC_Connection *gconn); non_null() void gcc_cleanup(const GC_Chat *chat); -#endif // C_TOXCORE_TOXCORE_GROUP_CONNECTION_H +#endif /* C_TOXCORE_TOXCORE_GROUP_CONNECTION_H */ diff --git a/toxcore/group_moderation.h b/toxcore/group_moderation.h index c57e0a81..ecf1c2ff 100644 --- a/toxcore/group_moderation.h +++ b/toxcore/group_moderation.h @@ -291,7 +291,7 @@ non_null() void sanctions_list_cleanup(Moderation *moderation); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_GROUP_MODERATION_H +#endif /* C_TOXCORE_TOXCORE_GROUP_MODERATION_H */ diff --git a/toxcore/group_onion_announce.h b/toxcore/group_onion_announce.h index 5c6d64ec..cb1e51e1 100644 --- a/toxcore/group_onion_announce.h +++ b/toxcore/group_onion_announce.h @@ -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 *gc_data, uint16_t gc_data_length); -#endif // C_TOXCORE_TOXCORE_GROUP_ONION_ANNOUNCE_H +#endif /* C_TOXCORE_TOXCORE_GROUP_ONION_ANNOUNCE_H */ diff --git a/toxcore/group_pack.h b/toxcore/group_pack.h index 70b0df8d..f6cef30e 100644 --- a/toxcore/group_pack.h +++ b/toxcore/group_pack.h @@ -37,4 +37,4 @@ bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out); non_null() 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 */ diff --git a/toxcore/list.h b/toxcore/list.h index a7c0e56c..ea01fb5f 100644 --- a/toxcore/list.h +++ b/toxcore/list.h @@ -68,7 +68,7 @@ non_null() bool bs_list_remove(BS_List *list, const uint8_t *data, int id); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif +#endif /* C_TOXCORE_TOXCORE_LIST_H */ diff --git a/toxcore/logger.c b/toxcore/logger.c index 468e9ad5..88e46625 100644 --- a/toxcore/logger.c +++ b/toxcore/logger.c @@ -43,7 +43,7 @@ static const char *logger_level_name(Logger_Level level) return ""; } -#endif +#endif /* NDEBUG */ 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, @@ -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, "Default stderr logger triggered; aborting program\n"); abort(); -#endif +#endif /* NDEBUG */ } 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. const char *windows_filename = strrchr(file, '\\'); file = windows_filename != nullptr ? windows_filename + 1 : file; -#endif +#endif /* WIN32 */ // Format message char msg[1024]; diff --git a/toxcore/logger.h b/toxcore/logger.h index 8388b166..eff63fa6 100644 --- a/toxcore/logger.h +++ b/toxcore/logger.h @@ -19,7 +19,7 @@ extern "C" { #ifndef MIN_LOGGER_LEVEL #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. typedef enum Logger_Level { @@ -100,7 +100,7 @@ void logger_abort(void); } while (0) #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_LOGGER_H +#endif /* C_TOXCORE_TOXCORE_LOGGER_H */ diff --git a/toxcore/mem.h b/toxcore/mem.h index a9d9e1d2..27ca4d57 100644 --- a/toxcore/mem.h +++ b/toxcore/mem.h @@ -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); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif +#endif /* C_TOXCORE_TOXCORE_MEM_H */ diff --git a/toxcore/mono_time.c b/toxcore/mono_time.c index 2c741f51..414370f6 100644 --- a/toxcore/mono_time.c +++ b/toxcore/mono_time.c @@ -4,31 +4,31 @@ */ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 600 -#endif +#endif /* _XOPEN_SOURCE */ #if !defined(OS_WIN32) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) #define OS_WIN32 -#endif +#endif /* WIN32 */ #include "mono_time.h" #ifdef OS_WIN32 #define WIN32_LEAN_AND_MEAN #include -#endif +#endif /* OS_WIN32 */ #ifdef __APPLE__ #include #include -#endif +#endif /* __APPLE__ */ #ifndef OS_WIN32 #include -#endif +#endif /* OS_WIN32 */ #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION #include -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ #include #include @@ -44,7 +44,7 @@ struct Mono_Time { #ifndef ESP_PLATFORM /* protect `time` from concurrent access */ pthread_rwlock_t *time_update_lock; -#endif +#endif /* ESP_PLATFORM */ mono_time_current_time_cb *current_time_callback; 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 // override the mono time callback. assert(user_data == nullptr); -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ struct timespec clock_mono; clock_gettime(CLOCK_MONOTONIC, &clock_mono); return timespec_to_u64(clock_mono); } -#endif // !__APPLE__ -#endif // !OS_WIN32 +#endif /* !__APPLE__ */ +#endif /* !OS_WIN32 */ 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; -#endif +#endif /* ESP_PLATFORM */ 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 // 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); -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ mono_time_update(mono_time); @@ -160,7 +160,7 @@ void mono_time_free(const Memory *mem, Mono_Time *mono_time) #ifndef ESP_PLATFORM pthread_rwlock_destroy(mono_time->time_update_lock); mem_delete(mem, mono_time->time_update_lock); -#endif +#endif /* ESP_PLATFORM */ mem_delete(mem, mono_time); } @@ -171,11 +171,11 @@ void mono_time_update(Mono_Time *mono_time) #ifndef ESP_PLATFORM pthread_rwlock_wrlock(mono_time->time_update_lock); -#endif +#endif /* ESP_PLATFORM */ mono_time->cur_time = cur_time; #ifndef ESP_PLATFORM pthread_rwlock_unlock(mono_time->time_update_lock); -#endif +#endif /* ESP_PLATFORM */ } 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) // Fuzzing is only single thread for now, no locking needed */ pthread_rwlock_rdlock(mono_time->time_update_lock); -#endif +#endif /* !ESP_PLATFORM */ const uint64_t cur_time = mono_time->cur_time; #if !defined(ESP_PLATFORM) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) pthread_rwlock_unlock(mono_time->time_update_lock); -#endif +#endif /* !ESP_PLATFORM */ return cur_time; } diff --git a/toxcore/mono_time.h b/toxcore/mono_time.h index bcd3d95b..d0f2b7a6 100644 --- a/toxcore/mono_time.h +++ b/toxcore/mono_time.h @@ -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); #ifdef __cplusplus -} +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_MONO_TIME_H +#endif /* C_TOXCORE_TOXCORE_MONO_TIME_H */ diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index d12546a8..e7e25bb0 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c @@ -3193,7 +3193,7 @@ static void kill_timedout(Net_Crypto *c, void *userdata) /* do_timeout_here(); */ } -#endif +#endif /* 0 */ } } diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index 60894ecf..4934c894 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h @@ -414,4 +414,4 @@ void do_net_crypto(Net_Crypto *c, void *userdata); nullable(1) void kill_net_crypto(Net_Crypto *c); -#endif +#endif /* C_TOXCORE_TOXCORE_NET_CRYPTO_H */ diff --git a/toxcore/network.c b/toxcore/network.c index 9c8bfdd2..24919e09 100644 --- a/toxcore/network.c +++ b/toxcore/network.c @@ -9,31 +9,31 @@ #ifdef __APPLE__ #define _DARWIN_C_SOURCE -#endif +#endif /* __APPLE__ */ // For Solaris. #ifdef __sun #define __EXTENSIONS__ 1 -#endif +#endif /* __sun */ // For Linux (and some BSDs). #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 700 -#endif +#endif /* _XOPEN_SOURCE */ #if defined(_WIN32) && defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WINXP #undef _WIN32_WINNT #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)) #define OS_WIN32 -#endif +#endif /* !defined(OS_WIN32) && (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) */ #if defined(OS_WIN32) && !defined(WINVER) // Windows XP #define WINVER 0x0501 -#endif +#endif /* defined(OS_WIN32) && !defined(WINVER) */ #include "network.h" @@ -41,7 +41,7 @@ #include // Plan 9 requires this is imported first // Comment line here to avoid reordering by source code formatters. #include -#endif +#endif /* PLAN9 */ #ifdef OS_WIN32 // Put win32 includes here // 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. #include #include -#endif +#endif /* OS_WIN32 */ #ifdef __APPLE__ #include #include -#endif +#endif /* __APPLE__ */ #if !defined(OS_WIN32) #include @@ -73,13 +73,13 @@ #ifdef __sun #include #include -#endif +#endif /* __sun */ #else #ifndef IPV6_V6ONLY #define IPV6_V6ONLY 27 -#endif -#endif +#endif /* IPV6_V6ONLY */ +#endif /* !defined(OS_WIN32) */ #include #include @@ -95,13 +95,13 @@ // Disable MSG_NOSIGNAL on systems not supporting it, e.g. Windows, FreeBSD #if !defined(MSG_NOSIGNAL) #define MSG_NOSIGNAL 0 -#endif +#endif /* !defined(MSG_NOSIGNAL) */ #ifndef IPV6_ADD_MEMBERSHIP #ifdef IPV6_JOIN_GROUP #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP -#endif -#endif +#endif /* IPV6_JOIN_GROUP */ +#endif /* IPV6_ADD_MEMBERSHIP */ 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 #ifndef IPV6_V6ONLY #define IPV6_V6ONLY 27 -#endif +#endif /* IPV6_V6ONLY */ 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; } -#endif +#endif /* !defined(OS_WIN32) */ static_assert(TOX_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) #define INADDR_LOOPBACK 0x7f000001 -#endif +#endif /* !defined(INADDR_LOOPBACK) */ static const IP empty_ip = {{0}}; @@ -372,7 +372,7 @@ IP6 get_ip6_loopback(void) #ifndef OS_WIN32 #define INVALID_SOCKET (-1) -#endif +#endif /* OS_WIN32 */ Socket net_invalid_socket(void) { @@ -488,7 +488,7 @@ static int sys_close(void *obj, int sock) return closesocket(sock); #else // !OS_WIN32 return close(sock); -#endif +#endif /* OS_WIN32 */ } non_null() @@ -518,7 +518,7 @@ static int sys_recvbuf(void *obj, int sock) #else int count = 0; ioctl(sock, FIONREAD, &count); -#endif +#endif /* OS_WIN32 */ return count; } @@ -603,14 +603,14 @@ const Network *system_network(void) if ((true)) { return nullptr; } -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ #ifdef OS_WIN32 WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR) { return nullptr; } -#endif +#endif /* OS_WIN32 */ return &system_network_obj; } @@ -620,9 +620,9 @@ void system_network_deinit(const Network *ns) { #ifdef OS_WIN32 WSACleanup(); -#endif +#endif /* OS_WIN32 */ } -#endif +#endif /* 0 */ non_null() 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; #else return true; -#endif +#endif /* __APPLE__ */ } bool set_socket_reuseaddr(const Network *ns, Socket sock) @@ -1287,7 +1287,7 @@ Networking_Core *new_networking_ex( } net_kill_strerror(strerror); -#endif +#endif /* ESP_PLATFORM */ } /* 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)) { return 0; } -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ if (address == nullptr || to == nullptr) { return 0; @@ -1750,7 +1750,7 @@ bool net_connect(const Memory *mem, const Logger *log, Socket sock, const IP_Por if ((true)) { return true; } -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ Ip_Ntoa ip_str; 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; return 1; } -#endif +#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ // It's not an IP address, so now we try doing a DNS lookup. struct addrinfo *infos; @@ -2019,14 +2019,14 @@ bool ipv6_ipv4_in_v6(const IP6 *a) int net_error(void) { -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +#ifdef OS_WIN32 return WSAGetLastError(); #else return errno; -#endif +#endif /* OS_WIN32 */ } -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +#ifdef OS_WIN32 char *net_new_strerror(int error) { char *str = nullptr; @@ -2066,7 +2066,7 @@ static const char *net_strerror_r(int error, char *tmp, size_t tmp_size) return tmp; } -#endif +#endif /* GNU */ char *net_new_strerror(int error) { char tmp[256]; @@ -2086,13 +2086,13 @@ char *net_new_strerror(int error) return str; } -#endif +#endif /* OS_WIN32 */ void net_kill_strerror(char *strerror) { -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +#ifdef OS_WIN32 LocalFree((char *)strerror); #else free(strerror); -#endif +#endif /* OS_WIN32 */ } diff --git a/toxcore/network.h b/toxcore/network.h index a69ef40b..3ce4a000 100644 --- a/toxcore/network.h +++ b/toxcore/network.h @@ -564,7 +564,7 @@ nullable(1) void kill_networking(Networking_Core *net); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif +#endif /* C_TOXCORE_TOXCORE_NETWORK_H */ diff --git a/toxcore/onion.h b/toxcore/onion.h index 732d926c..0bc59d70 100644 --- a/toxcore/onion.h +++ b/toxcore/onion.h @@ -155,4 +155,4 @@ nullable(1) void kill_onion(Onion *onion); -#endif +#endif /* C_TOXCORE_TOXCORE_ONION_H */ diff --git a/toxcore/onion_announce.h b/toxcore/onion_announce.h index 90195351..f8eb9e47 100644 --- a/toxcore/onion_announce.h +++ b/toxcore/onion_announce.h @@ -138,4 +138,4 @@ Onion_Announce *new_onion_announce(const Logger *log, const Memory *mem, const R nullable(1) void kill_onion_announce(Onion_Announce *onion_a); -#endif +#endif /* C_TOXCORE_TOXCORE_ONION_ANNOUNCE_H */ diff --git a/toxcore/onion_client.c b/toxcore/onion_client.c index 56441ce1..1553e100 100644 --- a/toxcore/onion_client.c +++ b/toxcore/onion_client.c @@ -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); } -#endif +#endif /* 0 */ crypto_memzero(&onion_c->friends_list[friend_num], sizeof(Onion_Friend)); unsigned int i; diff --git a/toxcore/onion_client.h b/toxcore/onion_client.h index e7d65101..c0bf37dd 100644 --- a/toxcore/onion_client.h +++ b/toxcore/onion_client.h @@ -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); non_null() bool onion_friend_is_groupchat(const Onion_Friend *onion_friend); -#endif +#endif /* C_TOXCORE_TOXCORE_ONION_CLIENT_H */ diff --git a/toxcore/ping.h b/toxcore/ping.h index c5613459..55ed44d3 100644 --- a/toxcore/ping.h +++ b/toxcore/ping.h @@ -45,4 +45,4 @@ void ping_iterate(Ping *ping); non_null() 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 */ diff --git a/toxcore/ping_array.h b/toxcore/ping_array.h index 5fc04017..2c3d2737 100644 --- a/toxcore/ping_array.h +++ b/toxcore/ping_array.h @@ -60,7 +60,7 @@ int32_t ping_array_check(Ping_Array *array, const Mono_Time *mono_time, uint8_t uint64_t ping_id); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_PING_ARRAY_H +#endif /* C_TOXCORE_TOXCORE_PING_ARRAY_H */ diff --git a/toxcore/shared_key_cache.h b/toxcore/shared_key_cache.h index b7112720..1ff341ad 100644 --- a/toxcore/shared_key_cache.h +++ b/toxcore/shared_key_cache.h @@ -51,4 +51,4 @@ void shared_key_cache_free(Shared_Key_Cache *cache); non_null() 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 */ diff --git a/toxcore/state.c b/toxcore/state.c index 69f11f3c..09d82726 100644 --- a/toxcore/state.c +++ b/toxcore/state.c @@ -86,7 +86,7 @@ uint16_t lendian_to_host16(uint16_t lendian) return (lendian << 8) | (lendian >> 8); #else return lendian; -#endif +#endif /* WORDS_BIGENDIAN */ } 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 << 16) & 0xFFFF0000FFFF0000) | ((num >> 16) & 0xFFFF0000FFFF); num = (num << 32) | (num >> 32); -#endif +#endif /* WORDS_BIGENDIAN */ 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 << 16) & 0xFFFF0000FFFF0000) | ((d >> 16) & 0xFFFF0000FFFF); d = (d << 32) | (d >> 32); -#endif +#endif /* WORDS_BIGENDIAN */ *dest = d; } @@ -121,7 +121,7 @@ void host_to_lendian_bytes32(uint8_t *dest, uint32_t num) #ifdef WORDS_BIGENDIAN num = ((num << 8) & 0xFF00FF00) | ((num >> 8) & 0xFF00FF); num = (num << 16) | (num >> 16); -#endif +#endif /* WORDS_BIGENDIAN */ 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 d = ((d << 8) & 0xFF00FF00) | ((d >> 8) & 0xFF00FF); d = (d << 16) | (d >> 16); -#endif +#endif /* WORDS_BIGENDIAN */ *dest = d; } @@ -140,7 +140,7 @@ void host_to_lendian_bytes16(uint8_t *dest, uint16_t num) { #ifdef WORDS_BIGENDIAN num = (num << 8) | (num >> 8); -#endif +#endif /* WORDS_BIGENDIAN */ 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)); #ifdef WORDS_BIGENDIAN d = (d << 8) | (d >> 8); -#endif +#endif /* WORDS_BIGENDIAN */ *dest = d; } diff --git a/toxcore/state.h b/toxcore/state.h index 9b163e6e..e070f3a2 100644 --- a/toxcore/state.h +++ b/toxcore/state.h @@ -82,7 +82,7 @@ non_null() void lendian_bytes_to_host16(uint16_t *dest, const uint8_t *lendian); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_STATE_H +#endif /* C_TOXCORE_TOXCORE_STATE_H */ diff --git a/toxcore/timed_auth.h b/toxcore/timed_auth.h index 691b04d0..6f7c4d32 100644 --- a/toxcore/timed_auth.h +++ b/toxcore/timed_auth.h @@ -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) 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); -#endif +#endif /* C_TOXCORE_TOXCORE_TIMED_AUTH_H */ diff --git a/toxcore/tox.c b/toxcore/tox.c index e89a8709..42425854 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -8,7 +8,7 @@ */ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 600 -#endif +#endif /* _XOPEN_SOURCE */ #include "tox.h" diff --git a/toxcore/tox.h b/toxcore/tox.h index 183ec1b0..28440095 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -5731,7 +5731,7 @@ void tox_callback_group_moderation(Tox *tox, tox_group_moderation_cb *callback); /** @} */ #ifdef __cplusplus -} +} /* extern "C" */ #endif //!TOKSTYLE- @@ -5780,4 +5780,4 @@ typedef enum Tox_File_Kind TOX_FILE_KIND; #endif //!TOKSTYLE+ -#endif // C_TOXCORE_TOXCORE_TOX_H +#endif /* C_TOXCORE_TOXCORE_TOX_H */ diff --git a/toxcore/tox_dispatch.h b/toxcore/tox_dispatch.h index 76da61b7..85a1cfe2 100644 --- a/toxcore/tox_dispatch.h +++ b/toxcore/tox_dispatch.h @@ -214,7 +214,7 @@ void tox_events_callback_dht_get_nodes_response( Tox_Dispatch *dispatch, tox_events_dht_get_nodes_response_cb *callback); #ifdef __cplusplus -} +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_TOX_DISPATCH_H +#endif /* C_TOXCORE_TOXCORE_TOX_DISPATCH_H */ diff --git a/toxcore/tox_event.h b/toxcore/tox_event.h index 04d9a8a4..fa98aae2 100644 --- a/toxcore/tox_event.h +++ b/toxcore/tox_event.h @@ -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); #ifdef __cplusplus -} +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_TOX_EVENT_H +#endif /* C_TOXCORE_TOXCORE_TOX_EVENT_H */ diff --git a/toxcore/tox_events.c b/toxcore/tox_events.c index a0b53bbe..fe930a37 100644 --- a/toxcore/tox_events.c +++ b/toxcore/tox_events.c @@ -109,9 +109,9 @@ Tox_Events *tox_events_iterate(Tox *tox, bool fail_hard, Tox_Err_Events_Iterate } 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); return tox_event_pack(&events[index], bp); } diff --git a/toxcore/tox_events.h b/toxcore/tox_events.h index 5bc5087f..3edaa7d0 100644 --- a/toxcore/tox_events.h +++ b/toxcore/tox_events.h @@ -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); #ifdef __cplusplus -} +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_TOX_EVENTS_H +#endif /* C_TOXCORE_TOXCORE_TOX_EVENTS_H */ diff --git a/toxcore/tox_pack.h b/toxcore/tox_pack.h index 4e554bce..ea8605dc 100644 --- a/toxcore/tox_pack.h +++ b/toxcore/tox_pack.h @@ -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_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 */ diff --git a/toxcore/tox_private.h b/toxcore/tox_private.h index 14b209d3..b6434eb5 100644 --- a/toxcore/tox_private.h +++ b/toxcore/tox_private.h @@ -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); #ifdef __cplusplus -} +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_TOX_PRIVATE_H +#endif /* C_TOXCORE_TOXCORE_TOX_PRIVATE_H */ diff --git a/toxcore/tox_struct.h b/toxcore/tox_struct.h index b298269a..5b0de20f 100644 --- a/toxcore/tox_struct.h +++ b/toxcore/tox_struct.h @@ -67,7 +67,7 @@ struct Tox { }; #ifdef __cplusplus -} +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_TOX_STRUCT_H +#endif /* C_TOXCORE_TOXCORE_TOX_STRUCT_H */ diff --git a/toxcore/tox_unpack.h b/toxcore/tox_unpack.h index 1f2118cb..828d2947 100644 --- a/toxcore/tox_unpack.h +++ b/toxcore/tox_unpack.h @@ -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_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 */ diff --git a/toxcore/util.c b/toxcore/util.c index 9a0a26a7..532b68ab 100644 --- a/toxcore/util.c +++ b/toxcore/util.c @@ -9,7 +9,7 @@ */ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 600 -#endif +#endif /* _XOPEN_SOURCE */ #include "util.h" diff --git a/toxcore/util.h b/toxcore/util.h index 8c212cfb..be44f287 100644 --- a/toxcore/util.h +++ b/toxcore/util.h @@ -84,7 +84,7 @@ non_null() uint16_t data_checksum(const uint8_t *data, uint32_t length); #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // C_TOXCORE_TOXCORE_UTIL_H +#endif /* C_TOXCORE_TOXCORE_UTIL_H */ diff --git a/toxencryptsave/defines.h b/toxencryptsave/defines.h index 71c0f105..ac80cc78 100644 --- a/toxencryptsave/defines.h +++ b/toxencryptsave/defines.h @@ -9,4 +9,4 @@ #define TOX_ENC_SAVE_MAGIC_NUMBER ((const uint8_t *)"toxEsave") #define TOX_ENC_SAVE_MAGIC_LENGTH 8 -#endif +#endif /* C_TOXCORE_TOXENCRYPTSAVE_DEFINES_H */ diff --git a/toxencryptsave/toxencryptsave.h b/toxencryptsave/toxencryptsave.h index 4bc532ad..60251706 100644 --- a/toxencryptsave/toxencryptsave.h +++ b/toxencryptsave/toxencryptsave.h @@ -362,7 +362,7 @@ bool tox_is_data_encrypted(const uint8_t data[TOX_PASS_ENCRYPTION_EXTRA_LENGTH]) #ifdef __cplusplus -} +} /* extern "C" */ #endif //!TOKSTYLE- @@ -374,4 +374,4 @@ typedef Tox_Err_Get_Salt TOX_ERR_GET_SALT; //!TOKSTYLE+ -#endif // C_TOXCORE_TOXENCRYPTSAVE_TOXENCRYPTSAVE_H +#endif /* C_TOXCORE_TOXENCRYPTSAVE_TOXENCRYPTSAVE_H */