diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-09-18 01:31:55 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-09-24 21:53:50 +0100 |
commit | 15cb4261665bab4ef02a5b1b9db48b9477c9b87a (patch) | |
tree | d0c40a45afa19fff26ce1eb5bb703e18a9acdd4a /auto_tests | |
parent | 0d347c2b2e69aa09b079f6daaa00007fef4fe52f (diff) |
Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/TCP_test.c | 6 | ||||
-rw-r--r-- | auto_tests/dht_test.c | 17 | ||||
-rw-r--r-- | auto_tests/onion_test.c | 10 | ||||
-rw-r--r-- | auto_tests/tox_test.c | 2 | ||||
-rw-r--r-- | auto_tests/toxav_many_test.c | 8 |
5 files changed, 24 insertions, 19 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 05f42a6a..1442dcae 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -132,7 +132,7 @@ struct sec_TCP_con { | |||
132 | 132 | ||
133 | static struct sec_TCP_con *new_TCP_con(TCP_Server *tcp_s) | 133 | static struct sec_TCP_con *new_TCP_con(TCP_Server *tcp_s) |
134 | { | 134 | { |
135 | struct sec_TCP_con *sec_c = malloc(sizeof(struct sec_TCP_con)); | 135 | struct sec_TCP_con *sec_c = (struct sec_TCP_con *)malloc(sizeof(struct sec_TCP_con)); |
136 | sock_t sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); | 136 | sock_t sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); |
137 | struct sockaddr_in6 addr6_loopback = {0}; | 137 | struct sockaddr_in6 addr6_loopback = {0}; |
138 | addr6_loopback.sin6_family = AF_INET6; | 138 | addr6_loopback.sin6_family = AF_INET6; |
@@ -636,6 +636,8 @@ static bool tcp_oobdata_callback_called; | |||
636 | static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigned int id, const uint8_t *data, | 636 | static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigned int id, const uint8_t *data, |
637 | uint16_t length, void *userdata) | 637 | uint16_t length, void *userdata) |
638 | { | 638 | { |
639 | TCP_Connections *tcp_c = (TCP_Connections *)object; | ||
640 | |||
639 | if (length != 6) { | 641 | if (length != 6) { |
640 | return -1; | 642 | return -1; |
641 | } | 643 | } |
@@ -644,7 +646,7 @@ static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigne | |||
644 | return -1; | 646 | return -1; |
645 | } | 647 | } |
646 | 648 | ||
647 | if (tcp_send_oob_packet(object, id, public_key, data, length) == 0) { | 649 | if (tcp_send_oob_packet(tcp_c, id, public_key, data, length) == 0) { |
648 | tcp_oobdata_callback_called = 1; | 650 | tcp_oobdata_callback_called = 1; |
649 | } | 651 | } |
650 | 652 | ||
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index 08044637..7b22e515 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -528,11 +528,14 @@ static void test_list_main(void) | |||
528 | } | 528 | } |
529 | 529 | ||
530 | ck_assert_msg(count == 1, "Nodes in search don't know ip of friend. %u %u %u", i, j, count); | 530 | ck_assert_msg(count == 1, "Nodes in search don't know ip of friend. %u %u %u", i, j, count); |
531 | /* | 531 | #if 0 |
532 | for (k = 0; k < MAX_SENT_NODES; ++k) { | 532 | |
533 | printf("----gn %u----\n", k); | 533 | for (k = 0; k < MAX_SENT_NODES; ++k) { |
534 | print_pk(ln[k].public_key); | 534 | printf("----gn %u----\n", k); |
535 | }*/ | 535 | print_pk(ln[k].public_key); |
536 | } | ||
537 | |||
538 | #endif | ||
536 | ++m_count; | 539 | ++m_count; |
537 | } | 540 | } |
538 | } | 541 | } |
@@ -542,7 +545,7 @@ static void test_list_main(void) | |||
542 | (NUM_DHT) * (MAX_FRIEND_CLIENTS)); | 545 | (NUM_DHT) * (MAX_FRIEND_CLIENTS)); |
543 | 546 | ||
544 | for (i = 0; i < NUM_DHT; ++i) { | 547 | for (i = 0; i < NUM_DHT; ++i) { |
545 | void *n = dhts[i]->net; | 548 | Networking_Core *n = dhts[i]->net; |
546 | kill_DHT(dhts[i]); | 549 | kill_DHT(dhts[i]); |
547 | kill_networking(n); | 550 | kill_networking(n); |
548 | } | 551 | } |
@@ -643,7 +646,7 @@ loop_top: | |||
643 | } | 646 | } |
644 | 647 | ||
645 | for (i = 0; i < NUM_DHT; ++i) { | 648 | for (i = 0; i < NUM_DHT; ++i) { |
646 | void *n = dhts[i]->net; | 649 | Networking_Core *n = dhts[i]->net; |
647 | kill_DHT(dhts[i]); | 650 | kill_DHT(dhts[i]); |
648 | kill_networking(n); | 651 | kill_networking(n); |
649 | } | 652 | } |
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 6e330091..ee9df7a0 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -32,7 +32,7 @@ static void do_onion(Onion *onion) | |||
32 | static int handled_test_1; | 32 | static int handled_test_1; |
33 | static int handle_test_1(void *object, IP_Port source, const uint8_t *packet, uint16_t length, void *userdata) | 33 | static int handle_test_1(void *object, IP_Port source, const uint8_t *packet, uint16_t length, void *userdata) |
34 | { | 34 | { |
35 | Onion *onion = object; | 35 | Onion *onion = (Onion *)object; |
36 | 36 | ||
37 | if (memcmp(packet, "Install Gentoo", sizeof("Install Gentoo")) != 0) { | 37 | if (memcmp(packet, "Install Gentoo", sizeof("Install Gentoo")) != 0) { |
38 | return 1; | 38 | return 1; |
@@ -79,7 +79,7 @@ static uint8_t test_3_pub_key[crypto_box_PUBLICKEYBYTES]; | |||
79 | static uint8_t test_3_ping_id[crypto_hash_sha256_BYTES]; | 79 | static uint8_t test_3_ping_id[crypto_hash_sha256_BYTES]; |
80 | static int handle_test_3(void *object, IP_Port source, const uint8_t *packet, uint16_t length, void *userdata) | 80 | static int handle_test_3(void *object, IP_Port source, const uint8_t *packet, uint16_t length, void *userdata) |
81 | { | 81 | { |
82 | Onion *onion = object; | 82 | Onion *onion = (Onion *)object; |
83 | 83 | ||
84 | if (length != (1 + crypto_box_NONCEBYTES + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + 1 + crypto_hash_sha256_BYTES + | 84 | if (length != (1 + crypto_box_NONCEBYTES + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH + 1 + crypto_hash_sha256_BYTES + |
85 | crypto_box_MACBYTES)) { | 85 | crypto_box_MACBYTES)) { |
@@ -111,7 +111,7 @@ static uint8_t nonce[crypto_box_NONCEBYTES]; | |||
111 | static int handled_test_4; | 111 | static int handled_test_4; |
112 | static int handle_test_4(void *object, IP_Port source, const uint8_t *packet, uint16_t length, void *userdata) | 112 | static int handle_test_4(void *object, IP_Port source, const uint8_t *packet, uint16_t length, void *userdata) |
113 | { | 113 | { |
114 | Onion *onion = object; | 114 | Onion *onion = (Onion *)object; |
115 | 115 | ||
116 | if (length != (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + sizeof("Install gentoo") + | 116 | if (length != (1 + crypto_box_NONCEBYTES + crypto_box_PUBLICKEYBYTES + sizeof("Install gentoo") + |
117 | crypto_box_MACBYTES)) { | 117 | crypto_box_MACBYTES)) { |
@@ -284,7 +284,7 @@ static Onions *new_onions(uint16_t port) | |||
284 | IP ip; | 284 | IP ip; |
285 | ip_init(&ip, 1); | 285 | ip_init(&ip, 1); |
286 | ip.ip6.uint8[15] = 1; | 286 | ip.ip6.uint8[15] = 1; |
287 | Onions *on = malloc(sizeof(Onions)); | 287 | Onions *on = (Onions *)malloc(sizeof(Onions)); |
288 | DHT *dht = new_DHT(NULL, new_networking(NULL, ip, port)); | 288 | DHT *dht = new_DHT(NULL, new_networking(NULL, ip, port)); |
289 | on->onion = new_onion(dht); | 289 | on->onion = new_onion(dht); |
290 | on->onion_a = new_onion_announce(dht); | 290 | on->onion_a = new_onion_announce(dht); |
@@ -346,7 +346,7 @@ static uint8_t last_dht_pk[crypto_box_PUBLICKEYBYTES]; | |||
346 | static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key, void *userdata) | 346 | static void dht_pk_callback(void *object, int32_t number, const uint8_t *dht_public_key, void *userdata) |
347 | { | 347 | { |
348 | if ((NUM_FIRST == number && !first) || (NUM_LAST == number && !last)) { | 348 | if ((NUM_FIRST == number && !first) || (NUM_LAST == number && !last)) { |
349 | Onions *on = object; | 349 | Onions *on = (Onions *)object; |
350 | uint16_t count = 0; | 350 | uint16_t count = 0; |
351 | int ret = DHT_addfriend(on->onion->dht, dht_public_key, &dht_ip_callback, object, number, &count); | 351 | int ret = DHT_addfriend(on->onion->dht, dht_public_key, &dht_ip_callback, object, number, &count); |
352 | ck_assert_msg(ret == 0, "DHT_addfriend() did not return 0"); | 352 | ck_assert_msg(ret == 0, "DHT_addfriend() did not return 0"); |
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index a5745fe8..6ab03365 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -974,7 +974,7 @@ START_TEST(test_many_clients_tcp) | |||
974 | tox_callback_friend_request(toxes[i], accept_friend_request); | 974 | tox_callback_friend_request(toxes[i], accept_friend_request); |
975 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; | 975 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; |
976 | tox_self_get_dht_id(toxes[0], dpk); | 976 | tox_self_get_dht_id(toxes[0], dpk); |
977 | TOX_ERR_BOOTSTRAP error = 0; | 977 | TOX_ERR_BOOTSTRAP error = TOX_ERR_BOOTSTRAP_OK; |
978 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT, dpk, &error), "add relay error, %i, %i", i, | 978 | ck_assert_msg(tox_add_tcp_relay(toxes[i], TOX_LOCALHOST, TCP_RELAY_PORT, dpk, &error), "add relay error, %i, %i", i, |
979 | error); | 979 | error); |
980 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, 33445, dpk, 0), "Bootstrap error"); | 980 | ck_assert_msg(tox_bootstrap(toxes[i], TOX_LOCALHOST, 33445, dpk, 0), "Bootstrap error"); |
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index fec2a1de..6f864f07 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -164,10 +164,10 @@ static void *call_thread(void *pd) | |||
164 | 164 | ||
165 | c_sleep(30); | 165 | c_sleep(30); |
166 | 166 | ||
167 | int16_t *PCM = calloc(960, sizeof(int16_t)); | 167 | int16_t *PCM = (int16_t *)calloc(960, sizeof(int16_t)); |
168 | uint8_t *video_y = calloc(800 * 600, sizeof(uint8_t)); | 168 | uint8_t *video_y = (uint8_t *)calloc(800 * 600, sizeof(uint8_t)); |
169 | uint8_t *video_u = calloc(800 * 600 / 4, sizeof(uint8_t)); | 169 | uint8_t *video_u = (uint8_t *)calloc(800 * 600 / 4, sizeof(uint8_t)); |
170 | uint8_t *video_v = calloc(800 * 600 / 4, sizeof(uint8_t)); | 170 | uint8_t *video_v = (uint8_t *)calloc(800 * 600 / 4, sizeof(uint8_t)); |
171 | 171 | ||
172 | time_t start_time = time(NULL); | 172 | time_t start_time = time(NULL); |
173 | 173 | ||