diff options
author | iphydf <iphydf@users.noreply.github.com> | 2017-06-04 12:59:34 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2017-06-04 17:48:23 +0000 |
commit | 1e8fa85aadf602bdca3a540de09a8184f7139a6c (patch) | |
tree | 4caab80957f7f9a2098fb97e776be763defc44ab /toxcore/DHT.c | |
parent | 03f99bde2ecee3722d47a5b6a1031fc88e7210b7 (diff) |
Add a monolith_test that includes all toxcore sources.
This requires that every symbol, even if static (file-scope), is unique.
The idea is that we can easily run "whole" program static analysis on
programs that include monolith.h ("whole" is in quotes, as we don't
include dependencies like libsodium in this static analysis).
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r-- | toxcore/DHT.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 5ef24564..30e0b816 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -798,13 +798,13 @@ int get_close_nodes(const DHT *dht, const uint8_t *public_key, Node_format *node | |||
798 | typedef struct { | 798 | typedef struct { |
799 | const uint8_t *base_public_key; | 799 | const uint8_t *base_public_key; |
800 | Client_data entry; | 800 | Client_data entry; |
801 | } Cmp_data; | 801 | } DHT_Cmp_data; |
802 | 802 | ||
803 | static int cmp_dht_entry(const void *a, const void *b) | 803 | static int cmp_dht_entry(const void *a, const void *b) |
804 | { | 804 | { |
805 | Cmp_data cmp1, cmp2; | 805 | DHT_Cmp_data cmp1, cmp2; |
806 | memcpy(&cmp1, a, sizeof(Cmp_data)); | 806 | memcpy(&cmp1, a, sizeof(DHT_Cmp_data)); |
807 | memcpy(&cmp2, b, sizeof(Cmp_data)); | 807 | memcpy(&cmp2, b, sizeof(DHT_Cmp_data)); |
808 | Client_data entry1 = cmp1.entry; | 808 | Client_data entry1 = cmp1.entry; |
809 | Client_data entry2 = cmp2.entry; | 809 | Client_data entry2 = cmp2.entry; |
810 | const uint8_t *cmp_public_key = cmp1.base_public_key; | 810 | const uint8_t *cmp_public_key = cmp1.base_public_key; |
@@ -871,14 +871,14 @@ static void sort_client_list(Client_data *list, unsigned int length, const uint8 | |||
871 | { | 871 | { |
872 | // Pass comp_public_key to qsort with each Client_data entry, so the | 872 | // Pass comp_public_key to qsort with each Client_data entry, so the |
873 | // comparison function can use it as the base of comparison. | 873 | // comparison function can use it as the base of comparison. |
874 | VLA(Cmp_data, cmp_list, length); | 874 | VLA(DHT_Cmp_data, cmp_list, length); |
875 | 875 | ||
876 | for (uint32_t i = 0; i < length; i++) { | 876 | for (uint32_t i = 0; i < length; i++) { |
877 | cmp_list[i].base_public_key = comp_public_key; | 877 | cmp_list[i].base_public_key = comp_public_key; |
878 | cmp_list[i].entry = list[i]; | 878 | cmp_list[i].entry = list[i]; |
879 | } | 879 | } |
880 | 880 | ||
881 | qsort(cmp_list, length, sizeof(Cmp_data), cmp_dht_entry); | 881 | qsort(cmp_list, length, sizeof(DHT_Cmp_data), cmp_dht_entry); |
882 | 882 | ||
883 | for (uint32_t i = 0; i < length; i++) { | 883 | for (uint32_t i = 0; i < length; i++) { |
884 | list[i] = cmp_list[i].entry; | 884 | list[i] = cmp_list[i].entry; |
@@ -2736,7 +2736,7 @@ uint32_t DHT_size(const DHT *dht) | |||
2736 | return size32 + sizesubhead + (packed_node_size(AF_INET) * numv4) + (packed_node_size(AF_INET6) * numv6); | 2736 | return size32 + sizesubhead + (packed_node_size(AF_INET) * numv4) + (packed_node_size(AF_INET6) * numv6); |
2737 | } | 2737 | } |
2738 | 2738 | ||
2739 | static uint8_t *z_state_save_subheader(uint8_t *data, uint32_t len, uint16_t type) | 2739 | static uint8_t *DHT_save_subheader(uint8_t *data, uint32_t len, uint16_t type) |
2740 | { | 2740 | { |
2741 | host_to_lendian32(data, len); | 2741 | host_to_lendian32(data, len); |
2742 | data += sizeof(uint32_t); | 2742 | data += sizeof(uint32_t); |
@@ -2757,7 +2757,7 @@ void DHT_save(DHT *dht, uint8_t *data) | |||
2757 | uint8_t *old_data = data; | 2757 | uint8_t *old_data = data; |
2758 | 2758 | ||
2759 | /* get right offset. we write the actual header later. */ | 2759 | /* get right offset. we write the actual header later. */ |
2760 | data = z_state_save_subheader(data, 0, 0); | 2760 | data = DHT_save_subheader(data, 0, 0); |
2761 | 2761 | ||
2762 | Node_format clients[MAX_SAVED_DHT_NODES]; | 2762 | Node_format clients[MAX_SAVED_DHT_NODES]; |
2763 | 2763 | ||
@@ -2793,7 +2793,7 @@ void DHT_save(DHT *dht, uint8_t *data) | |||
2793 | } | 2793 | } |
2794 | } | 2794 | } |
2795 | 2795 | ||
2796 | z_state_save_subheader(old_data, pack_nodes(data, sizeof(Node_format) * num, clients, num), DHT_STATE_TYPE_NODES); | 2796 | DHT_save_subheader(old_data, pack_nodes(data, sizeof(Node_format) * num, clients, num), DHT_STATE_TYPE_NODES); |
2797 | } | 2797 | } |
2798 | 2798 | ||
2799 | /* Bootstrap from this number of nodes every time DHT_connect_after_load() is called */ | 2799 | /* Bootstrap from this number of nodes every time DHT_connect_after_load() is called */ |