diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-28 21:30:39 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-30 23:35:50 +0000 |
commit | 92ffad1a72bc8c422426d52ac408bd71242dd047 (patch) | |
tree | f592f353068dd2043525dd2cc04d6124a4ed4bc4 /auto_tests/dht_test.c | |
parent | 623e9ac331df7323660e21c8a2226523a5ee713b (diff) |
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
Diffstat (limited to 'auto_tests/dht_test.c')
-rw-r--r-- | auto_tests/dht_test.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index c426d3e8..227b43f7 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #ifndef _XOPEN_SOURCE | ||
1 | #define _XOPEN_SOURCE 600 | 2 | #define _XOPEN_SOURCE 600 |
3 | #endif | ||
2 | 4 | ||
3 | #ifdef HAVE_CONFIG_H | 5 | #ifdef HAVE_CONFIG_H |
4 | #include "config.h" | 6 | #include "config.h" |
@@ -11,7 +13,9 @@ | |||
11 | 13 | ||
12 | #include "helpers.h" | 14 | #include "helpers.h" |
13 | 15 | ||
16 | #ifndef DHT_C_INCLUDED | ||
14 | #include "../toxcore/DHT.c" | 17 | #include "../toxcore/DHT.c" |
18 | #endif // DHT_C_INCLUDED | ||
15 | #include "../toxcore/tox.h" | 19 | #include "../toxcore/tox.h" |
16 | 20 | ||
17 | 21 | ||
@@ -325,11 +329,11 @@ static void test_addto_lists_good(DHT *dht, | |||
325 | 329 | ||
326 | static void test_addto_lists(IP ip) | 330 | static void test_addto_lists(IP ip) |
327 | { | 331 | { |
328 | Networking_Core *net = new_networking(NULL, ip, TOX_PORT_DEFAULT); | 332 | Networking_Core *net = new_networking(nullptr, ip, TOX_PORT_DEFAULT); |
329 | ck_assert_msg(net != 0, "Failed to create Networking_Core"); | 333 | ck_assert_msg(net != nullptr, "Failed to create Networking_Core"); |
330 | 334 | ||
331 | DHT *dht = new_DHT(NULL, net, true); | 335 | DHT *dht = new_DHT(nullptr, net, true); |
332 | ck_assert_msg(dht != 0, "Failed to create DHT"); | 336 | ck_assert_msg(dht != nullptr, "Failed to create DHT"); |
333 | 337 | ||
334 | IP_Port ip_port = { .ip = ip, .port = TOX_PORT_DEFAULT }; | 338 | IP_Port ip_port = { .ip = ip, .port = TOX_PORT_DEFAULT }; |
335 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 339 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
@@ -466,8 +470,8 @@ static void test_list_main(void) | |||
466 | IP ip; | 470 | IP ip; |
467 | ip_init(&ip, 1); | 471 | ip_init(&ip, 1); |
468 | 472 | ||
469 | dhts[i] = new_DHT(NULL, new_networking(NULL, ip, DHT_DEFAULT_PORT + i), true); | 473 | dhts[i] = new_DHT(nullptr, new_networking(nullptr, ip, DHT_DEFAULT_PORT + i), true); |
470 | ck_assert_msg(dhts[i] != 0, "Failed to create dht instances %u", i); | 474 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); |
471 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); | 475 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); |
472 | } | 476 | } |
473 | 477 | ||
@@ -602,8 +606,8 @@ START_TEST(test_DHT_test) | |||
602 | IP ip; | 606 | IP ip; |
603 | ip_init(&ip, 1); | 607 | ip_init(&ip, 1); |
604 | 608 | ||
605 | dhts[i] = new_DHT(NULL, new_networking(NULL, ip, DHT_DEFAULT_PORT + i), true); | 609 | dhts[i] = new_DHT(nullptr, new_networking(nullptr, ip, DHT_DEFAULT_PORT + i), true); |
606 | ck_assert_msg(dhts[i] != 0, "Failed to create dht instances %u", i); | 610 | ck_assert_msg(dhts[i] != nullptr, "Failed to create dht instances %u", i); |
607 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); | 611 | ck_assert_msg(net_port(dhts[i]->net) != DHT_DEFAULT_PORT + i, "Bound to wrong port"); |
608 | } | 612 | } |
609 | 613 | ||
@@ -652,7 +656,7 @@ loop_top: | |||
652 | } | 656 | } |
653 | 657 | ||
654 | for (i = 0; i < NUM_DHT; ++i) { | 658 | for (i = 0; i < NUM_DHT; ++i) { |
655 | networking_poll(dhts[i]->net, NULL); | 659 | networking_poll(dhts[i]->net, nullptr); |
656 | do_DHT(dhts[i]); | 660 | do_DHT(dhts[i]); |
657 | } | 661 | } |
658 | 662 | ||
@@ -715,7 +719,7 @@ static void dht_pack_unpack(const Node_format *nodes, size_t size, uint8_t *data | |||
715 | 719 | ||
716 | static void random_ip(IP_Port *ipp, int family) | 720 | static void random_ip(IP_Port *ipp, int family) |
717 | { | 721 | { |
718 | uint8_t *ip = NULL; | 722 | uint8_t *ip = nullptr; |
719 | size_t size; | 723 | size_t size; |
720 | 724 | ||
721 | if (family == TOX_AF_INET || family == TCP_INET) { | 725 | if (family == TOX_AF_INET || family == TCP_INET) { |
@@ -797,7 +801,7 @@ static Suite *dht_suite(void) | |||
797 | 801 | ||
798 | int main(int argc, char *argv[]) | 802 | int main(int argc, char *argv[]) |
799 | { | 803 | { |
800 | srand((unsigned int) time(NULL)); | 804 | srand((unsigned int) time(nullptr)); |
801 | 805 | ||
802 | Suite *dht = dht_suite(); | 806 | Suite *dht = dht_suite(); |
803 | SRunner *test_runner = srunner_create(dht); | 807 | SRunner *test_runner = srunner_create(dht); |