diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-02-23 02:22:38 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-02-24 22:20:22 +0000 |
commit | d3b286cb434ed228e7b62cc70cb293e7a5554bfa (patch) | |
tree | 9ab3dd66f9dba2ca861ba8c6e098fb96754aa80b /auto_tests | |
parent | afc80922e720f5d2a93bdfb3745da058e5ddf81b (diff) |
Fix a bunch of compiler warnings and remove suppressions.
Diffstat (limited to 'auto_tests')
30 files changed, 102 insertions, 71 deletions
diff --git a/auto_tests/BUILD.bazel b/auto_tests/BUILD.bazel index 88951f97..af8920b1 100644 --- a/auto_tests/BUILD.bazel +++ b/auto_tests/BUILD.bazel | |||
@@ -11,10 +11,7 @@ cc_library( | |||
11 | name = src[:-2], | 11 | name = src[:-2], |
12 | size = "small", | 12 | size = "small", |
13 | srcs = [src], | 13 | srcs = [src], |
14 | copts = [ | 14 | copts = ["-Wno-sign-compare"], |
15 | "-Wno-parentheses", | ||
16 | "-Wno-sign-compare", | ||
17 | ], | ||
18 | deps = [ | 15 | deps = [ |
19 | ":helpers", | 16 | ":helpers", |
20 | "//c-toxcore/other:monolith", | 17 | "//c-toxcore/other:monolith", |
@@ -37,10 +34,7 @@ cc_test( | |||
37 | name = "monolith_test", | 34 | name = "monolith_test", |
38 | size = "small", | 35 | size = "small", |
39 | srcs = ["monolith_test.cpp"], | 36 | srcs = ["monolith_test.cpp"], |
40 | copts = [ | 37 | copts = ["-Wno-sign-compare"], |
41 | "-Wno-parentheses", | ||
42 | "-Wno-sign-compare", | ||
43 | ], | ||
44 | deps = [ | 38 | deps = [ |
45 | ":helpers", | 39 | ":helpers", |
46 | ":monolith", | 40 | ":monolith", |
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index b14f53f2..686419a6 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -28,10 +28,8 @@ | |||
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #if !USE_IPV6 | 30 | #if !USE_IPV6 |
31 | # undef TOX_AF_INET6 | 31 | #undef TOX_AF_INET6 |
32 | # define TOX_AF_INET6 TOX_AF_INET | 32 | #define TOX_AF_INET6 TOX_AF_INET |
33 | # define get_ip6_loopback get_ip4_loopback | ||
34 | # define IP6 IP4 | ||
35 | #endif | 33 | #endif |
36 | 34 | ||
37 | static inline IP get_loopback() | 35 | static inline IP get_loopback() |
@@ -769,7 +767,7 @@ static Suite *TCP_suite(void) | |||
769 | return s; | 767 | return s; |
770 | } | 768 | } |
771 | 769 | ||
772 | int main(int argc, char *argv[]) | 770 | int main(void) |
773 | { | 771 | { |
774 | setvbuf(stdout, nullptr, _IONBF, 0); | 772 | setvbuf(stdout, nullptr, _IONBF, 0); |
775 | 773 | ||
diff --git a/auto_tests/check_compat.h b/auto_tests/check_compat.h index 755dea81..badf18c8 100644 --- a/auto_tests/check_compat.h +++ b/auto_tests/check_compat.h | |||
@@ -16,26 +16,26 @@ typedef struct Suite Suite; | |||
16 | typedef struct SRunner SRunner; | 16 | typedef struct SRunner SRunner; |
17 | enum SRunMode { CK_NORMAL }; | 17 | enum SRunMode { CK_NORMAL }; |
18 | 18 | ||
19 | Suite *suite_create(const char *title) | 19 | static inline Suite *suite_create(const char *title) |
20 | { | 20 | { |
21 | printf("Running test suite: %s\n", title); | 21 | printf("Running test suite: %s\n", title); |
22 | return nullptr; | 22 | return nullptr; |
23 | } | 23 | } |
24 | 24 | ||
25 | SRunner *srunner_create(Suite *s) | 25 | static inline SRunner *srunner_create(Suite *s) |
26 | { | 26 | { |
27 | return nullptr; | 27 | return nullptr; |
28 | } | 28 | } |
29 | 29 | ||
30 | void srunner_free(SRunner *s) | 30 | static inline void srunner_free(SRunner *s) |
31 | { | 31 | { |
32 | } | 32 | } |
33 | 33 | ||
34 | void srunner_run_all(SRunner *r, int mode) | 34 | static inline void srunner_run_all(SRunner *r, int mode) |
35 | { | 35 | { |
36 | } | 36 | } |
37 | 37 | ||
38 | int srunner_ntests_failed(SRunner *r) | 38 | static inline int srunner_ntests_failed(SRunner *r) |
39 | { | 39 | { |
40 | return 0; | 40 | return 0; |
41 | } | 41 | } |
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c index 72c81de3..9e784e85 100644 --- a/auto_tests/conference_test.c +++ b/auto_tests/conference_test.c | |||
@@ -252,7 +252,7 @@ static void test_many_group(void) | |||
252 | printf("test_many_group succeeded, took %d seconds\n", (int)(time(nullptr) - test_start_time)); | 252 | printf("test_many_group succeeded, took %d seconds\n", (int)(time(nullptr) - test_start_time)); |
253 | } | 253 | } |
254 | 254 | ||
255 | int main(int argc, char *argv[]) | 255 | int main(void) |
256 | { | 256 | { |
257 | setvbuf(stdout, nullptr, _IONBF, 0); | 257 | setvbuf(stdout, nullptr, _IONBF, 0); |
258 | 258 | ||
diff --git a/auto_tests/crypto_test.c b/auto_tests/crypto_test.c index e2c4e307..3b95dcc1 100644 --- a/auto_tests/crypto_test.c +++ b/auto_tests/crypto_test.c | |||
@@ -354,7 +354,7 @@ static Suite *crypto_suite(void) | |||
354 | return s; | 354 | return s; |
355 | } | 355 | } |
356 | 356 | ||
357 | int main(int argc, char *argv[]) | 357 | int main(void) |
358 | { | 358 | { |
359 | setvbuf(stdout, nullptr, _IONBF, 0); | 359 | setvbuf(stdout, nullptr, _IONBF, 0); |
360 | srand((unsigned int) time(nullptr)); | 360 | srand((unsigned int) time(nullptr)); |
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index 516e1a8e..fe23a598 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -22,13 +22,6 @@ | |||
22 | // These tests currently fail. | 22 | // These tests currently fail. |
23 | static bool enable_broken_tests = false; | 23 | static bool enable_broken_tests = false; |
24 | 24 | ||
25 | #define swap(x,y) do \ | ||
26 | { unsigned char swap_temp[sizeof(x) == sizeof(y) ? (signed)sizeof(x) : -1]; \ | ||
27 | memcpy(swap_temp,&y,sizeof(x)); \ | ||
28 | memcpy(&y,&x, sizeof(x)); \ | ||
29 | memcpy(&x,swap_temp,sizeof(x)); \ | ||
30 | } while(0) | ||
31 | |||
32 | #ifndef USE_IPV6 | 25 | #ifndef USE_IPV6 |
33 | #define USE_IPV6 1 | 26 | #define USE_IPV6 1 |
34 | #endif | 27 | #endif |
@@ -335,7 +328,9 @@ static void test_addto_lists(IP ip) | |||
335 | DHT *dht = new_DHT(nullptr, net, true); | 328 | DHT *dht = new_DHT(nullptr, net, true); |
336 | ck_assert_msg(dht != nullptr, "Failed to create DHT"); | 329 | ck_assert_msg(dht != nullptr, "Failed to create DHT"); |
337 | 330 | ||
338 | IP_Port ip_port = { .ip = ip, .port = TOX_PORT_DEFAULT }; | 331 | IP_Port ip_port; |
332 | ip_port.ip = ip; | ||
333 | ip_port.port = TOX_PORT_DEFAULT; | ||
339 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 334 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
340 | int i, used; | 335 | int i, used; |
341 | 336 | ||
@@ -413,8 +408,6 @@ END_TEST | |||
413 | 408 | ||
414 | #define DHT_DEFAULT_PORT (TOX_PORT_DEFAULT + 20) | 409 | #define DHT_DEFAULT_PORT (TOX_PORT_DEFAULT + 20) |
415 | 410 | ||
416 | #define DHT_LIST_LENGTH 128 | ||
417 | |||
418 | static void print_pk(uint8_t *public_key) | 411 | static void print_pk(uint8_t *public_key) |
419 | { | 412 | { |
420 | uint32_t j; | 413 | uint32_t j; |
@@ -799,7 +792,7 @@ static Suite *dht_suite(void) | |||
799 | return s; | 792 | return s; |
800 | } | 793 | } |
801 | 794 | ||
802 | int main(int argc, char *argv[]) | 795 | int main(void) |
803 | { | 796 | { |
804 | setvbuf(stdout, nullptr, _IONBF, 0); | 797 | setvbuf(stdout, nullptr, _IONBF, 0); |
805 | srand((unsigned int) time(nullptr)); | 798 | srand((unsigned int) time(nullptr)); |
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c index 41769dad..48a43c86 100644 --- a/auto_tests/encryptsave_test.c +++ b/auto_tests/encryptsave_test.c | |||
@@ -204,7 +204,7 @@ static Suite *encryptsave_suite(void) | |||
204 | return s; | 204 | return s; |
205 | } | 205 | } |
206 | 206 | ||
207 | int main(int argc, char *argv[]) | 207 | int main(void) |
208 | { | 208 | { |
209 | setvbuf(stdout, nullptr, _IONBF, 0); | 209 | setvbuf(stdout, nullptr, _IONBF, 0); |
210 | srand((unsigned int) time(nullptr)); | 210 | srand((unsigned int) time(nullptr)); |
diff --git a/auto_tests/file_transfer_test.c b/auto_tests/file_transfer_test.c index ab66ddd0..7fe780b8 100644 --- a/auto_tests/file_transfer_test.c +++ b/auto_tests/file_transfer_test.c | |||
@@ -287,7 +287,11 @@ START_TEST(test_few_clients) | |||
287 | 287 | ||
288 | printf("Starting file streaming transfer test.\n"); | 288 | printf("Starting file streaming transfer test.\n"); |
289 | 289 | ||
290 | file_sending_done = file_accepted = file_size = sendf_ok = size_recv = 0; | 290 | file_sending_done = 0; |
291 | file_accepted = 0; | ||
292 | file_size = 0; | ||
293 | sendf_ok = 0; | ||
294 | size_recv = 0; | ||
291 | file_recv = 0; | 295 | file_recv = 0; |
292 | tox_callback_file_recv_chunk(tox3, write_file); | 296 | tox_callback_file_recv_chunk(tox3, write_file); |
293 | tox_callback_file_recv_control(tox2, file_print_control); | 297 | tox_callback_file_recv_control(tox2, file_print_control); |
@@ -335,7 +339,11 @@ START_TEST(test_few_clients) | |||
335 | 339 | ||
336 | printf("Starting file 0 transfer test.\n"); | 340 | printf("Starting file 0 transfer test.\n"); |
337 | 341 | ||
338 | file_sending_done = file_accepted = file_size = sendf_ok = size_recv = 0; | 342 | file_sending_done = 0; |
343 | file_accepted = 0; | ||
344 | file_size = 0; | ||
345 | sendf_ok = 0; | ||
346 | size_recv = 0; | ||
339 | file_recv = 0; | 347 | file_recv = 0; |
340 | tox_callback_file_recv_chunk(tox3, write_file); | 348 | tox_callback_file_recv_chunk(tox3, write_file); |
341 | tox_callback_file_recv_control(tox2, file_print_control); | 349 | tox_callback_file_recv_control(tox2, file_print_control); |
@@ -395,7 +403,7 @@ static Suite *tox_suite(void) | |||
395 | return s; | 403 | return s; |
396 | } | 404 | } |
397 | 405 | ||
398 | int main(int argc, char *argv[]) | 406 | int main(void) |
399 | { | 407 | { |
400 | setvbuf(stdout, nullptr, _IONBF, 0); | 408 | setvbuf(stdout, nullptr, _IONBF, 0); |
401 | srand((unsigned int) time(nullptr)); | 409 | srand((unsigned int) time(nullptr)); |
diff --git a/auto_tests/friend_request_test.c b/auto_tests/friend_request_test.c index d9987cfc..2fbc2166 100644 --- a/auto_tests/friend_request_test.c +++ b/auto_tests/friend_request_test.c | |||
@@ -83,7 +83,7 @@ static void test_friend_request(void) | |||
83 | tox_kill(tox2); | 83 | tox_kill(tox2); |
84 | } | 84 | } |
85 | 85 | ||
86 | int main(int argc, char *argv[]) | 86 | int main(void) |
87 | { | 87 | { |
88 | setvbuf(stdout, nullptr, _IONBF, 0); | 88 | setvbuf(stdout, nullptr, _IONBF, 0); |
89 | 89 | ||
diff --git a/auto_tests/helpers.h b/auto_tests/helpers.h index fbb2ff04..bebde35b 100644 --- a/auto_tests/helpers.h +++ b/auto_tests/helpers.h | |||
@@ -19,6 +19,8 @@ | |||
19 | 19 | ||
20 | #define ITERATION_INTERVAL 200 | 20 | #define ITERATION_INTERVAL 200 |
21 | 21 | ||
22 | Tox *tox_new_log(struct Tox_Options *options, TOX_ERR_NEW *err, void *log_user_data); | ||
23 | |||
22 | static const char *tox_log_level_name(TOX_LOG_LEVEL level) | 24 | static const char *tox_log_level_name(TOX_LOG_LEVEL level) |
23 | { | 25 | { |
24 | switch (level) { | 26 | switch (level) { |
@@ -54,7 +56,7 @@ static void print_debug_log(Tox *m, TOX_LOG_LEVEL level, const char *path, uint3 | |||
54 | fprintf(stderr, "[#%d] %s %s:%d\t%s:\t%s\n", index, tox_log_level_name(level), file, line, func, message); | 56 | fprintf(stderr, "[#%d] %s %s:%d\t%s:\t%s\n", index, tox_log_level_name(level), file, line, func, message); |
55 | } | 57 | } |
56 | 58 | ||
57 | Tox *tox_new_log_lan(struct Tox_Options *options, TOX_ERR_NEW *err, void *log_user_data, bool lan_discovery) | 59 | static Tox *tox_new_log_lan(struct Tox_Options *options, TOX_ERR_NEW *err, void *log_user_data, bool lan_discovery) |
58 | { | 60 | { |
59 | struct Tox_Options *log_options = options; | 61 | struct Tox_Options *log_options = options; |
60 | 62 | ||
diff --git a/auto_tests/lossless_packet_test.c b/auto_tests/lossless_packet_test.c index b5185757..05d56c4d 100644 --- a/auto_tests/lossless_packet_test.c +++ b/auto_tests/lossless_packet_test.c | |||
@@ -103,7 +103,7 @@ static void test_lossless_packet(void) | |||
103 | tox_kill(tox2); | 103 | tox_kill(tox2); |
104 | } | 104 | } |
105 | 105 | ||
106 | int main(int argc, char *argv[]) | 106 | int main(void) |
107 | { | 107 | { |
108 | setvbuf(stdout, nullptr, _IONBF, 0); | 108 | setvbuf(stdout, nullptr, _IONBF, 0); |
109 | 109 | ||
diff --git a/auto_tests/lossy_packet_test.c b/auto_tests/lossy_packet_test.c index d225a62b..c0af148f 100644 --- a/auto_tests/lossy_packet_test.c +++ b/auto_tests/lossy_packet_test.c | |||
@@ -100,7 +100,7 @@ static void test_lossy_packet(void) | |||
100 | tox_kill(tox2); | 100 | tox_kill(tox2); |
101 | } | 101 | } |
102 | 102 | ||
103 | int main(int argc, char *argv[]) | 103 | int main(void) |
104 | { | 104 | { |
105 | setvbuf(stdout, nullptr, _IONBF, 0); | 105 | setvbuf(stdout, nullptr, _IONBF, 0); |
106 | 106 | ||
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index 9d797b55..12b00fd7 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c | |||
@@ -25,14 +25,13 @@ | |||
25 | #include <string.h> | 25 | #include <string.h> |
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | 27 | ||
28 | #if VANILLA_NACL | 28 | #ifdef VANILLA_NACL |
29 | #include <crypto_box.h> // crypto_box_PUBLICKEYBYTES and other defines. | 29 | #include <crypto_box.h> // crypto_box_PUBLICKEYBYTES and other defines. |
30 | #else | 30 | #else |
31 | #include <sodium.h> | 31 | #include <sodium.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #define REALLY_BIG_NUMBER ((1) << (sizeof(uint16_t) * 7)) | 34 | #define REALLY_BIG_NUMBER ((1) << (sizeof(uint16_t) * 7)) |
35 | #define STRINGS_EQUAL(X, Y) (strcmp(X, Y) == 0) | ||
36 | 35 | ||
37 | static bool enable_broken_tests = false; | 36 | static bool enable_broken_tests = false; |
38 | 37 | ||
@@ -213,7 +212,7 @@ START_TEST(test_m_copy_userstatus) | |||
213 | assert(m_copy_userstatus(REALLY_BIG_NUMBER, buf, MAX_USERSTATUS_LENGTH) == -1); | 212 | assert(m_copy_userstatus(REALLY_BIG_NUMBER, buf, MAX_USERSTATUS_LENGTH) == -1); |
214 | m_copy_userstatus(friend_id_num, buf, MAX_USERSTATUS_LENGTH + 6); | 213 | m_copy_userstatus(friend_id_num, buf, MAX_USERSTATUS_LENGTH + 6); |
215 | 214 | ||
216 | assert(STRINGS_EQUAL(name_buf, friend_id_status)); | 215 | assert(strcmp(name_buf, friend_id_status) == 0); |
217 | } | 216 | } |
218 | END_TEST | 217 | END_TEST |
219 | #endif | 218 | #endif |
@@ -346,7 +345,7 @@ static Suite *messenger_suite(void) | |||
346 | return s; | 345 | return s; |
347 | } | 346 | } |
348 | 347 | ||
349 | int main(int argc, char *argv[]) | 348 | int main(void) |
350 | { | 349 | { |
351 | setvbuf(stdout, nullptr, _IONBF, 0); | 350 | setvbuf(stdout, nullptr, _IONBF, 0); |
352 | 351 | ||
diff --git a/auto_tests/monolith_test.cpp b/auto_tests/monolith_test.cpp index 99703acf..60bafeb5 100644 --- a/auto_tests/monolith_test.cpp +++ b/auto_tests/monolith_test.cpp | |||
@@ -8,8 +8,9 @@ | |||
8 | #include <net/if.h> | 8 | #include <net/if.h> |
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #ifdef __APPLE__ | ||
11 | #define _DARWIN_C_SOURCE | 12 | #define _DARWIN_C_SOURCE |
12 | #define _XOPEN_SOURCE 600 | 13 | #endif |
13 | 14 | ||
14 | #ifdef HAVE_CONFIG_H | 15 | #ifdef HAVE_CONFIG_H |
15 | #include "config.h" | 16 | #include "config.h" |
@@ -26,130 +27,162 @@ | |||
26 | 27 | ||
27 | namespace TCP_test | 28 | namespace TCP_test |
28 | { | 29 | { |
30 | int main(void); | ||
29 | #include "TCP_test.c" | 31 | #include "TCP_test.c" |
30 | } | 32 | } |
31 | namespace bootstrap_test | 33 | namespace bootstrap_test |
32 | { | 34 | { |
35 | int main(void); | ||
33 | #include "bootstrap_test.c" | 36 | #include "bootstrap_test.c" |
34 | } | 37 | } |
35 | namespace conference_test | 38 | namespace conference_test |
36 | { | 39 | { |
40 | int main(void); | ||
37 | #include "conference_test.c" | 41 | #include "conference_test.c" |
38 | } | 42 | } |
39 | namespace crypto_test | 43 | namespace crypto_test |
40 | { | 44 | { |
45 | int main(void); | ||
41 | #include "crypto_test.c" | 46 | #include "crypto_test.c" |
42 | } | 47 | } |
43 | namespace dht_test | 48 | namespace dht_test |
44 | { | 49 | { |
50 | int main(void); | ||
45 | #include "dht_test.c" | 51 | #include "dht_test.c" |
46 | } | 52 | } |
47 | namespace encryptsave_test | 53 | namespace encryptsave_test |
48 | { | 54 | { |
55 | int main(void); | ||
49 | #include "encryptsave_test.c" | 56 | #include "encryptsave_test.c" |
50 | } | 57 | } |
51 | namespace file_saving_test | 58 | namespace file_saving_test |
52 | { | 59 | { |
60 | int main(void); | ||
53 | #include "file_saving_test.c" | 61 | #include "file_saving_test.c" |
54 | } | 62 | } |
55 | namespace friend_request_test | 63 | namespace friend_request_test |
56 | { | 64 | { |
65 | int main(void); | ||
57 | #include "friend_request_test.c" | 66 | #include "friend_request_test.c" |
58 | } | 67 | } |
59 | namespace lan_discovery_test | 68 | namespace lan_discovery_test |
60 | { | 69 | { |
70 | int main(void); | ||
61 | #include "lan_discovery_test.c" | 71 | #include "lan_discovery_test.c" |
62 | } | 72 | } |
63 | namespace lossless_packet_test | 73 | namespace lossless_packet_test |
64 | { | 74 | { |
75 | int main(void); | ||
65 | #include "lossless_packet_test.c" | 76 | #include "lossless_packet_test.c" |
66 | } | 77 | } |
67 | namespace lossy_packet_test | 78 | namespace lossy_packet_test |
68 | { | 79 | { |
80 | int main(void); | ||
69 | #include "lossy_packet_test.c" | 81 | #include "lossy_packet_test.c" |
70 | } | 82 | } |
71 | namespace messenger_test | 83 | namespace messenger_test |
72 | { | 84 | { |
85 | int main(void); | ||
73 | #include "messenger_test.c" | 86 | #include "messenger_test.c" |
74 | } | 87 | } |
75 | namespace network_test | 88 | namespace network_test |
76 | { | 89 | { |
90 | int main(void); | ||
77 | #include "network_test.c" | 91 | #include "network_test.c" |
78 | } | 92 | } |
79 | namespace onion_test | 93 | namespace onion_test |
80 | { | 94 | { |
95 | int main(void); | ||
81 | #include "onion_test.c" | 96 | #include "onion_test.c" |
82 | } | 97 | } |
83 | namespace resource_leak_test | 98 | namespace resource_leak_test |
84 | { | 99 | { |
100 | int main(void); | ||
85 | #include "resource_leak_test.c" | 101 | #include "resource_leak_test.c" |
86 | } | 102 | } |
87 | namespace save_friend_test | 103 | namespace save_friend_test |
88 | { | 104 | { |
105 | int main(void); | ||
89 | #include "save_friend_test.c" | 106 | #include "save_friend_test.c" |
90 | } | 107 | } |
91 | namespace save_load_test | 108 | namespace save_load_test |
92 | { | 109 | { |
110 | int main(void); | ||
93 | #include "save_load_test.c" | 111 | #include "save_load_test.c" |
94 | } | 112 | } |
95 | namespace selfname_change_conference_test | 113 | namespace selfname_change_conference_test |
96 | { | 114 | { |
115 | int main(void); | ||
97 | #include "selfname_change_conference_test.c" | 116 | #include "selfname_change_conference_test.c" |
98 | } | 117 | } |
99 | namespace self_conference_title_change_test | 118 | namespace self_conference_title_change_test |
100 | { | 119 | { |
120 | int main(void); | ||
101 | #include "self_conference_title_change_test.c" | 121 | #include "self_conference_title_change_test.c" |
102 | } | 122 | } |
103 | namespace send_message_test | 123 | namespace send_message_test |
104 | { | 124 | { |
125 | int main(void); | ||
105 | #include "send_message_test.c" | 126 | #include "send_message_test.c" |
106 | } | 127 | } |
107 | namespace set_name_test | 128 | namespace set_name_test |
108 | { | 129 | { |
130 | int main(void); | ||
109 | #include "set_name_test.c" | 131 | #include "set_name_test.c" |
110 | } | 132 | } |
111 | namespace set_status_message_test | 133 | namespace set_status_message_test |
112 | { | 134 | { |
135 | int main(void); | ||
113 | #include "set_status_message_test.c" | 136 | #include "set_status_message_test.c" |
114 | } | 137 | } |
115 | namespace simple_conference_test | 138 | namespace simple_conference_test |
116 | { | 139 | { |
140 | int main(void); | ||
117 | #include "simple_conference_test.c" | 141 | #include "simple_conference_test.c" |
118 | } | 142 | } |
119 | namespace skeleton_test | 143 | namespace skeleton_test |
120 | { | 144 | { |
145 | int main(void); | ||
121 | #include "skeleton_test.c" | 146 | #include "skeleton_test.c" |
122 | } | 147 | } |
123 | namespace toxav_basic_test | 148 | namespace toxav_basic_test |
124 | { | 149 | { |
150 | int main(void); | ||
125 | #include "toxav_basic_test.c" | 151 | #include "toxav_basic_test.c" |
126 | } | 152 | } |
127 | namespace toxav_many_test | 153 | namespace toxav_many_test |
128 | { | 154 | { |
155 | int main(void); | ||
129 | #include "toxav_many_test.c" | 156 | #include "toxav_many_test.c" |
130 | } | 157 | } |
131 | namespace tox_many_tcp_test | 158 | namespace tox_many_tcp_test |
132 | { | 159 | { |
160 | int main(void); | ||
133 | #include "tox_many_tcp_test.c" | 161 | #include "tox_many_tcp_test.c" |
134 | } | 162 | } |
135 | namespace tox_many_test | 163 | namespace tox_many_test |
136 | { | 164 | { |
165 | int main(void); | ||
137 | #include "tox_many_test.c" | 166 | #include "tox_many_test.c" |
138 | } | 167 | } |
139 | namespace tox_one_test | 168 | namespace tox_one_test |
140 | { | 169 | { |
170 | int main(void); | ||
141 | #include "tox_one_test.c" | 171 | #include "tox_one_test.c" |
142 | } | 172 | } |
143 | namespace tox_strncasecmp_test | 173 | namespace tox_strncasecmp_test |
144 | { | 174 | { |
175 | int main(void); | ||
145 | #include "tox_strncasecmp_test.c" | 176 | #include "tox_strncasecmp_test.c" |
146 | } | 177 | } |
147 | namespace typing_test | 178 | namespace typing_test |
148 | { | 179 | { |
180 | int main(void); | ||
149 | #include "typing_test.c" | 181 | #include "typing_test.c" |
150 | } | 182 | } |
151 | namespace version_test | 183 | namespace version_test |
152 | { | 184 | { |
185 | int main(void); | ||
153 | #include "version_test.c" | 186 | #include "version_test.c" |
154 | } | 187 | } |
155 | 188 | ||
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c index 760a7800..e3eb3e5e 100644 --- a/auto_tests/onion_test.c +++ b/auto_tests/onion_test.c | |||
@@ -536,7 +536,7 @@ static Suite *onion_suite(void) | |||
536 | return s; | 536 | return s; |
537 | } | 537 | } |
538 | 538 | ||
539 | int main(int argc, char *argv[]) | 539 | int main(void) |
540 | { | 540 | { |
541 | setvbuf(stdout, nullptr, _IONBF, 0); | 541 | setvbuf(stdout, nullptr, _IONBF, 0); |
542 | srand((unsigned int) time(nullptr)); | 542 | srand((unsigned int) time(nullptr)); |
diff --git a/auto_tests/resource_leak_test.c b/auto_tests/resource_leak_test.c index cf451ebd..55998b72 100644 --- a/auto_tests/resource_leak_test.c +++ b/auto_tests/resource_leak_test.c | |||
@@ -5,11 +5,12 @@ | |||
5 | #include "helpers.h" | 5 | #include "helpers.h" |
6 | 6 | ||
7 | // See man 2 sbrk. | 7 | // See man 2 sbrk. |
8 | #if _BSD_SOURCE || _SVID_SOURCE || \ | 8 | #if defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || \ |
9 | (_XOPEN_SOURCE >= 500 || \ | 9 | defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500 || defined(_XOPEN_SOURCE_EXTENDED)) && \ |
10 | _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && \ | 10 | !(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) |
11 | !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) | ||
12 | #define HAVE_SBRK 1 | 11 | #define HAVE_SBRK 1 |
12 | #else | ||
13 | #define HAVE_SBRK 0 | ||
13 | #endif | 14 | #endif |
14 | 15 | ||
15 | #if HAVE_SBRK | 16 | #if HAVE_SBRK |
diff --git a/auto_tests/save_friend_test.c b/auto_tests/save_friend_test.c index ad4bd338..a7b41f52 100644 --- a/auto_tests/save_friend_test.c +++ b/auto_tests/save_friend_test.c | |||
@@ -33,21 +33,22 @@ static void set_random(Tox *m, bool (*setter)(Tox *, const uint8_t *, size_t, TO | |||
33 | setter(m, text, SIZEOF_VLA(text), nullptr); | 33 | setter(m, text, SIZEOF_VLA(text), nullptr); |
34 | } | 34 | } |
35 | 35 | ||
36 | void namechange_callback(Tox *tox, uint32_t friend_number, const uint8_t *name, size_t length, void *user_data) | 36 | static void namechange_callback(Tox *tox, uint32_t friend_number, const uint8_t *name, size_t length, void *user_data) |
37 | { | 37 | { |
38 | struct test_data *to_compare = (struct test_data *)user_data; | 38 | struct test_data *to_compare = (struct test_data *)user_data; |
39 | memcpy(to_compare->name, name, length); | 39 | memcpy(to_compare->name, name, length); |
40 | to_compare->received_name = true; | 40 | to_compare->received_name = true; |
41 | } | 41 | } |
42 | 42 | ||
43 | void statuschange_callback(Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length, void *user_data) | 43 | static void statuschange_callback(Tox *tox, uint32_t friend_number, const uint8_t *message, size_t length, |
44 | void *user_data) | ||
44 | { | 45 | { |
45 | struct test_data *to_compare = (struct test_data *)user_data; | 46 | struct test_data *to_compare = (struct test_data *)user_data; |
46 | memcpy(to_compare->status_message, message, length); | 47 | memcpy(to_compare->status_message, message, length); |
47 | to_compare->received_status_message = true; | 48 | to_compare->received_status_message = true; |
48 | } | 49 | } |
49 | 50 | ||
50 | int main(int argc, char *argv[]) | 51 | int main(void) |
51 | { | 52 | { |
52 | setvbuf(stdout, nullptr, _IONBF, 0); | 53 | setvbuf(stdout, nullptr, _IONBF, 0); |
53 | 54 | ||
diff --git a/auto_tests/save_load_test.c b/auto_tests/save_load_test.c index ab4e0a8c..50facb2c 100644 --- a/auto_tests/save_load_test.c +++ b/auto_tests/save_load_test.c | |||
@@ -140,7 +140,7 @@ static void test_few_clients(void) | |||
140 | tox_kill(tox3); | 140 | tox_kill(tox3); |
141 | } | 141 | } |
142 | 142 | ||
143 | int main(int argc, char *argv[]) | 143 | int main(void) |
144 | { | 144 | { |
145 | setvbuf(stdout, nullptr, _IONBF, 0); | 145 | setvbuf(stdout, nullptr, _IONBF, 0); |
146 | 146 | ||
diff --git a/auto_tests/send_message_test.c b/auto_tests/send_message_test.c index 3a5088f3..35ef5a62 100644 --- a/auto_tests/send_message_test.c +++ b/auto_tests/send_message_test.c | |||
@@ -111,7 +111,7 @@ static void test_send_message(void) | |||
111 | tox_kill(tox2); | 111 | tox_kill(tox2); |
112 | } | 112 | } |
113 | 113 | ||
114 | int main(int argc, char *argv[]) | 114 | int main(void) |
115 | { | 115 | { |
116 | setvbuf(stdout, nullptr, _IONBF, 0); | 116 | setvbuf(stdout, nullptr, _IONBF, 0); |
117 | 117 | ||
diff --git a/auto_tests/set_name_test.c b/auto_tests/set_name_test.c index a7f01ec7..20fb0a67 100644 --- a/auto_tests/set_name_test.c +++ b/auto_tests/set_name_test.c | |||
@@ -97,7 +97,7 @@ static void test_set_name(void) | |||
97 | tox_kill(tox2); | 97 | tox_kill(tox2); |
98 | } | 98 | } |
99 | 99 | ||
100 | int main(int argc, char *argv[]) | 100 | int main(void) |
101 | { | 101 | { |
102 | setvbuf(stdout, nullptr, _IONBF, 0); | 102 | setvbuf(stdout, nullptr, _IONBF, 0); |
103 | 103 | ||
diff --git a/auto_tests/set_status_message_test.c b/auto_tests/set_status_message_test.c index f1508720..fd6c3558 100644 --- a/auto_tests/set_status_message_test.c +++ b/auto_tests/set_status_message_test.c | |||
@@ -104,7 +104,7 @@ static void test_set_status_message(void) | |||
104 | tox_kill(tox2); | 104 | tox_kill(tox2); |
105 | } | 105 | } |
106 | 106 | ||
107 | int main(int argc, char *argv[]) | 107 | int main(void) |
108 | { | 108 | { |
109 | setvbuf(stdout, nullptr, _IONBF, 0); | 109 | setvbuf(stdout, nullptr, _IONBF, 0); |
110 | 110 | ||
diff --git a/auto_tests/simple_conference_test.c b/auto_tests/simple_conference_test.c index ad17d02e..7e07c45a 100644 --- a/auto_tests/simple_conference_test.c +++ b/auto_tests/simple_conference_test.c | |||
@@ -47,11 +47,13 @@ static void handle_conference_invite(Tox *tox, uint32_t friend_number, TOX_CONFE | |||
47 | fprintf(stderr, "\nhandle_conference_invite(#%d, %d, %d, uint8_t[%zd], _)\n", state->id, friend_number, type, length); | 47 | fprintf(stderr, "\nhandle_conference_invite(#%d, %d, %d, uint8_t[%zd], _)\n", state->id, friend_number, type, length); |
48 | fprintf(stderr, "tox%d joining conference\n", state->id); | 48 | fprintf(stderr, "tox%d joining conference\n", state->id); |
49 | 49 | ||
50 | TOX_ERR_CONFERENCE_JOIN err; | 50 | { |
51 | state->conference = tox_conference_join(tox, friend_number, cookie, length, &err); | 51 | TOX_ERR_CONFERENCE_JOIN err; |
52 | assert(err == TOX_ERR_CONFERENCE_JOIN_OK); | 52 | state->conference = tox_conference_join(tox, friend_number, cookie, length, &err); |
53 | fprintf(stderr, "tox%d Joined conference %d\n", state->id, state->conference); | 53 | assert(err == TOX_ERR_CONFERENCE_JOIN_OK); |
54 | state->joined = true; | 54 | fprintf(stderr, "tox%d Joined conference %d\n", state->id, state->conference); |
55 | state->joined = true; | ||
56 | } | ||
55 | 57 | ||
56 | // We're tox2, so now we invite tox3. | 58 | // We're tox2, so now we invite tox3. |
57 | if (state->id == 2) { | 59 | if (state->id == 2) { |
@@ -101,7 +103,7 @@ static void handle_conference_namelist_change(Tox *tox, uint32_t conference_numb | |||
101 | } | 103 | } |
102 | } | 104 | } |
103 | 105 | ||
104 | int main() | 106 | int main(void) |
105 | { | 107 | { |
106 | setvbuf(stdout, nullptr, _IONBF, 0); | 108 | setvbuf(stdout, nullptr, _IONBF, 0); |
107 | 109 | ||
diff --git a/auto_tests/skeleton_test.c b/auto_tests/skeleton_test.c index ac9291d0..1d391a86 100644 --- a/auto_tests/skeleton_test.c +++ b/auto_tests/skeleton_test.c | |||
@@ -29,7 +29,7 @@ static Suite *creativesuitenamegoeshere_suite(void) | |||
29 | return s; | 29 | return s; |
30 | } | 30 | } |
31 | 31 | ||
32 | int main(int argc, char *argv[]) | 32 | int main(void) |
33 | { | 33 | { |
34 | setvbuf(stdout, nullptr, _IONBF, 0); | 34 | setvbuf(stdout, nullptr, _IONBF, 0); |
35 | 35 | ||
diff --git a/auto_tests/tox_many_tcp_test.c b/auto_tests/tox_many_tcp_test.c index 682e23a6..6c3f2350 100644 --- a/auto_tests/tox_many_tcp_test.c +++ b/auto_tests/tox_many_tcp_test.c | |||
@@ -250,7 +250,7 @@ static Suite *tox_suite(void) | |||
250 | return s; | 250 | return s; |
251 | } | 251 | } |
252 | 252 | ||
253 | int main(int argc, char *argv[]) | 253 | int main(void) |
254 | { | 254 | { |
255 | setvbuf(stdout, nullptr, _IONBF, 0); | 255 | setvbuf(stdout, nullptr, _IONBF, 0); |
256 | 256 | ||
diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c index a797d99c..29f3af68 100644 --- a/auto_tests/tox_many_test.c +++ b/auto_tests/tox_many_test.c | |||
@@ -130,7 +130,7 @@ loop_top: | |||
130 | printf("test_many_clients succeeded, took %ld seconds\n", time(nullptr) - cur_time); | 130 | printf("test_many_clients succeeded, took %ld seconds\n", time(nullptr) - cur_time); |
131 | } | 131 | } |
132 | 132 | ||
133 | int main(int argc, char *argv[]) | 133 | int main(void) |
134 | { | 134 | { |
135 | setvbuf(stdout, nullptr, _IONBF, 0); | 135 | setvbuf(stdout, nullptr, _IONBF, 0); |
136 | 136 | ||
diff --git a/auto_tests/tox_one_test.c b/auto_tests/tox_one_test.c index 4ac30326..f3323bc9 100644 --- a/auto_tests/tox_one_test.c +++ b/auto_tests/tox_one_test.c | |||
@@ -141,7 +141,7 @@ static Suite *tox_suite(void) | |||
141 | return s; | 141 | return s; |
142 | } | 142 | } |
143 | 143 | ||
144 | int main(int argc, char *argv[]) | 144 | int main(void) |
145 | { | 145 | { |
146 | setvbuf(stdout, nullptr, _IONBF, 0); | 146 | setvbuf(stdout, nullptr, _IONBF, 0); |
147 | 147 | ||
diff --git a/auto_tests/tox_strncasecmp_test.c b/auto_tests/tox_strncasecmp_test.c index 27105eca..377ec2e3 100644 --- a/auto_tests/tox_strncasecmp_test.c +++ b/auto_tests/tox_strncasecmp_test.c | |||
@@ -22,7 +22,7 @@ typedef enum { | |||
22 | 22 | ||
23 | static const char *Comparison_Str[] = { "NEGATIVE", "ZERO", "POSITIVE" }; | 23 | static const char *Comparison_Str[] = { "NEGATIVE", "ZERO", "POSITIVE" }; |
24 | 24 | ||
25 | void verify(const char *s1, const char *s2, size_t n, Comparison expected) | 25 | static void verify(const char *s1, const char *s2, size_t n, Comparison expected) |
26 | { | 26 | { |
27 | int r = tox_strncasecmp(s1, s2, n); | 27 | int r = tox_strncasecmp(s1, s2, n); |
28 | Comparison actual = r < 0 ? NEGATIVE : r == 0 ? ZERO : POSITIVE; | 28 | Comparison actual = r < 0 ? NEGATIVE : r == 0 ? ZERO : POSITIVE; |
@@ -177,7 +177,7 @@ static Suite *tox_strncasecmp_suite(void) | |||
177 | return s; | 177 | return s; |
178 | } | 178 | } |
179 | 179 | ||
180 | int main(int argc, char *argv[]) | 180 | int main(void) |
181 | { | 181 | { |
182 | setvbuf(stdout, nullptr, _IONBF, 0); | 182 | setvbuf(stdout, nullptr, _IONBF, 0); |
183 | 183 | ||
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index 5c27e11f..b2b92255 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c | |||
@@ -559,7 +559,7 @@ static void test_av_flows(void) | |||
559 | printf("\nTest successful!\n"); | 559 | printf("\nTest successful!\n"); |
560 | } | 560 | } |
561 | 561 | ||
562 | int main(int argc, char *argv[]) | 562 | int main(void) |
563 | { | 563 | { |
564 | setvbuf(stdout, nullptr, _IONBF, 0); | 564 | setvbuf(stdout, nullptr, _IONBF, 0); |
565 | 565 | ||
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 4de1a867..ed4aa211 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -326,7 +326,7 @@ static void test_av_three_calls(void) | |||
326 | printf("\nTest successful!\n"); | 326 | printf("\nTest successful!\n"); |
327 | } | 327 | } |
328 | 328 | ||
329 | int main(int argc, char *argv[]) | 329 | int main(void) |
330 | { | 330 | { |
331 | setvbuf(stdout, nullptr, _IONBF, 0); | 331 | setvbuf(stdout, nullptr, _IONBF, 0); |
332 | 332 | ||
diff --git a/auto_tests/typing_test.c b/auto_tests/typing_test.c index 837ed757..1262fa3d 100644 --- a/auto_tests/typing_test.c +++ b/auto_tests/typing_test.c | |||
@@ -102,7 +102,7 @@ static void test_typing(void) | |||
102 | tox_kill(tox2); | 102 | tox_kill(tox2); |
103 | } | 103 | } |
104 | 104 | ||
105 | int main(int argc, char *argv[]) | 105 | int main(void) |
106 | { | 106 | { |
107 | setvbuf(stdout, nullptr, _IONBF, 0); | 107 | setvbuf(stdout, nullptr, _IONBF, 0); |
108 | 108 | ||