diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 19:12:19 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 20:04:16 +0100 |
commit | 633da98ae69866efb195e00d9a3a22ace6bada66 (patch) | |
tree | 875535f3d2257c4ea5bb97a553b2f1beab4a1590 /auto_tests/dht_test.c | |
parent | 6356eb4e4fe407fa7870f2a685d0d08b5c2ec5bb (diff) |
Add braces to all if statements.
Diffstat (limited to 'auto_tests/dht_test.c')
-rw-r--r-- | auto_tests/dht_test.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index 369356b5..b5d979f4 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -47,10 +47,11 @@ void mark_all_good(Client_data *list, uint32_t length, uint8_t ipv6) | |||
47 | uint32_t i; | 47 | uint32_t i; |
48 | 48 | ||
49 | for (i = 0; i < length; ++i) { | 49 | for (i = 0; i < length; ++i) { |
50 | if (ipv6) | 50 | if (ipv6) { |
51 | mark_good(&list[i].assoc6); | 51 | mark_good(&list[i].assoc6); |
52 | else | 52 | } else { |
53 | mark_good(&list[i].assoc4); | 53 | mark_good(&list[i].assoc4); |
54 | } | ||
54 | } | 55 | } |
55 | } | 56 | } |
56 | 57 | ||
@@ -60,9 +61,11 @@ uint8_t is_furthest(const uint8_t *comp_client_id, Client_data *list, uint32_t l | |||
60 | { | 61 | { |
61 | uint32_t i; | 62 | uint32_t i; |
62 | 63 | ||
63 | for (i = 0; i < length; ++i) | 64 | for (i = 0; i < length; ++i) { |
64 | if (id_closest(comp_client_id, public_key, list[i].public_key) == 1) | 65 | if (id_closest(comp_client_id, public_key, list[i].public_key) == 1) { |
65 | return 0; | 66 | return 0; |
67 | } | ||
68 | } | ||
66 | 69 | ||
67 | return 1; | 70 | return 1; |
68 | } | 71 | } |
@@ -71,9 +74,11 @@ int client_in_list(Client_data *list, uint32_t length, const uint8_t *public_key | |||
71 | { | 74 | { |
72 | int i; | 75 | int i; |
73 | 76 | ||
74 | for (i = 0; i < (int)length; ++i) | 77 | for (i = 0; i < (int)length; ++i) { |
75 | if (id_equal(public_key, list[i].public_key)) | 78 | if (id_equal(public_key, list[i].public_key)) { |
76 | return i; | 79 | return i; |
80 | } | ||
81 | } | ||
77 | 82 | ||
78 | return -1; | 83 | return -1; |
79 | } | 84 | } |
@@ -120,8 +125,11 @@ void test_addto_lists_update(DHT *dht, | |||
120 | ipport_copy(&test_ipp, ipv6 ? &list[test1].assoc6.ip_port : &list[test1].assoc4.ip_port); | 125 | ipport_copy(&test_ipp, ipv6 ? &list[test1].assoc6.ip_port : &list[test1].assoc4.ip_port); |
121 | id_copy(test_id, list[test2].public_key); | 126 | id_copy(test_id, list[test2].public_key); |
122 | 127 | ||
123 | if (ipv6) list[test2].assoc6.ip_port.port = -1; | 128 | if (ipv6) { |
124 | else list[test2].assoc4.ip_port.port = -1; | 129 | list[test2].assoc6.ip_port.port = -1; |
130 | } else { | ||
131 | list[test2].assoc4.ip_port.port = -1; | ||
132 | } | ||
125 | 133 | ||
126 | used = addto_lists(dht, test_ipp, test_id); | 134 | used = addto_lists(dht, test_ipp, test_id); |
127 | ck_assert_msg(used >= 1, "Wrong number of added clients"); | 135 | ck_assert_msg(used >= 1, "Wrong number of added clients"); |
@@ -136,8 +144,11 @@ void test_addto_lists_update(DHT *dht, | |||
136 | ipport_copy(&test_ipp, ipv6 ? &list[test2].assoc6.ip_port : &list[test2].assoc4.ip_port); | 144 | ipport_copy(&test_ipp, ipv6 ? &list[test2].assoc6.ip_port : &list[test2].assoc4.ip_port); |
137 | id_copy(test_id, list[test1].public_key); | 145 | id_copy(test_id, list[test1].public_key); |
138 | 146 | ||
139 | if (ipv6) list[test1].assoc6.ip_port.port = -1; | 147 | if (ipv6) { |
140 | else list[test1].assoc4.ip_port.port = -1; | 148 | list[test1].assoc6.ip_port.port = -1; |
149 | } else { | ||
150 | list[test1].assoc4.ip_port.port = -1; | ||
151 | } | ||
141 | 152 | ||
142 | used = addto_lists(dht, test_ipp, test_id); | 153 | used = addto_lists(dht, test_ipp, test_id); |
143 | ck_assert_msg(used >= 1, "Wrong number of added clients"); | 154 | ck_assert_msg(used >= 1, "Wrong number of added clients"); |
@@ -441,8 +452,9 @@ void test_list_main() | |||
441 | 452 | ||
442 | for (j = 0; j < NUM_DHT; ++j) { | 453 | for (j = 0; j < NUM_DHT; ++j) { |
443 | for (i = 0; i < NUM_DHT; ++i) { | 454 | for (i = 0; i < NUM_DHT; ++i) { |
444 | if (i == j) | 455 | if (i == j) { |
445 | continue; | 456 | continue; |
457 | } | ||
446 | 458 | ||
447 | IP_Port ip_port; | 459 | IP_Port ip_port; |
448 | ip_init(&ip_port.ip, 0); | 460 | ip_init(&ip_port.ip, 0); |
@@ -467,15 +479,17 @@ void test_list_main() | |||
467 | for (l = 0; l < NUM_DHT; ++l) { | 479 | for (l = 0; l < NUM_DHT; ++l) { |
468 | for (i = 0; i < MAX_FRIEND_CLIENTS; ++i) { | 480 | for (i = 0; i < MAX_FRIEND_CLIENTS; ++i) { |
469 | for (j = 1; j < NUM_DHT; ++j) { | 481 | for (j = 1; j < NUM_DHT; ++j) { |
470 | if (memcmp(cmp_list1[l][i], dhts[(l + j) % NUM_DHT]->self_public_key, crypto_box_PUBLICKEYBYTES) != 0) | 482 | if (memcmp(cmp_list1[l][i], dhts[(l + j) % NUM_DHT]->self_public_key, crypto_box_PUBLICKEYBYTES) != 0) { |
471 | continue; | 483 | continue; |
484 | } | ||
472 | 485 | ||
473 | unsigned int count = 0; | 486 | unsigned int count = 0; |
474 | 487 | ||
475 | for (k = 0; k < LCLIENT_LIST; ++k) { | 488 | for (k = 0; k < LCLIENT_LIST; ++k) { |
476 | if (memcmp(dhts[l]->self_public_key, dhts[(l + j) % NUM_DHT]->close_clientlist[k].public_key, | 489 | if (memcmp(dhts[l]->self_public_key, dhts[(l + j) % NUM_DHT]->close_clientlist[k].public_key, |
477 | crypto_box_PUBLICKEYBYTES) == 0) | 490 | crypto_box_PUBLICKEYBYTES) == 0) { |
478 | ++count; | 491 | ++count; |
492 | } | ||
479 | } | 493 | } |
480 | 494 | ||
481 | if (count != 1) { | 495 | if (count != 1) { |
@@ -504,8 +518,9 @@ void test_list_main() | |||
504 | count = 0; | 518 | count = 0; |
505 | 519 | ||
506 | for (k = 0; k < MAX_SENT_NODES; ++k) { | 520 | for (k = 0; k < MAX_SENT_NODES; ++k) { |
507 | if (memcmp(dhts[l]->self_public_key, ln[k].public_key, crypto_box_PUBLICKEYBYTES) == 0) | 521 | if (memcmp(dhts[l]->self_public_key, ln[k].public_key, crypto_box_PUBLICKEYBYTES) == 0) { |
508 | ++count; | 522 | ++count; |
523 | } | ||
509 | } | 524 | } |
510 | 525 | ||
511 | ck_assert_msg(count == 1, "Nodes in search don't know ip of friend. %u %u %u", i, j, count); | 526 | ck_assert_msg(count == 1, "Nodes in search don't know ip of friend. %u %u %u", i, j, count); |
@@ -534,8 +549,9 @@ START_TEST(test_list) | |||
534 | { | 549 | { |
535 | unsigned int i; | 550 | unsigned int i; |
536 | 551 | ||
537 | for (i = 0; i < 10; ++i) | 552 | for (i = 0; i < 10; ++i) { |
538 | test_list_main(); | 553 | test_list_main(); |
554 | } | ||
539 | } | 555 | } |
540 | END_TEST | 556 | END_TEST |
541 | 557 | ||
@@ -582,8 +598,9 @@ loop_top: | |||
582 | pairs[i].tox2 = (pairs[i].tox1 + (rand() % (NUM_DHT - 1)) + 1) % NUM_DHT; | 598 | pairs[i].tox2 = (pairs[i].tox1 + (rand() % (NUM_DHT - 1)) + 1) % NUM_DHT; |
583 | 599 | ||
584 | for (j = 0; j < i; ++j) { | 600 | for (j = 0; j < i; ++j) { |
585 | if (pairs[j].tox2 == pairs[i].tox2 && pairs[j].tox1 == pairs[i].tox1) | 601 | if (pairs[j].tox2 == pairs[i].tox2 && pairs[j].tox1 == pairs[i].tox1) { |
586 | goto loop_top; | 602 | goto loop_top; |
603 | } | ||
587 | } | 604 | } |
588 | 605 | ||
589 | uint16_t lock_count = 0; | 606 | uint16_t lock_count = 0; |
@@ -606,8 +623,9 @@ loop_top: | |||
606 | for (i = 0; i < NUM_DHT_FRIENDS; ++i) { | 623 | for (i = 0; i < NUM_DHT_FRIENDS; ++i) { |
607 | IP_Port a; | 624 | IP_Port a; |
608 | 625 | ||
609 | if (DHT_getfriendip(dhts[pairs[i].tox2], dhts[pairs[i].tox1]->self_public_key, &a) == 1) | 626 | if (DHT_getfriendip(dhts[pairs[i].tox2], dhts[pairs[i].tox1]->self_public_key, &a) == 1) { |
610 | ++counter; | 627 | ++counter; |
628 | } | ||
611 | } | 629 | } |
612 | 630 | ||
613 | if (counter == NUM_DHT_FRIENDS) { | 631 | if (counter == NUM_DHT_FRIENDS) { |