diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-07-08 14:55:26 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-07-08 18:23:45 +0000 |
commit | ebdc43285a4fdf1f9d76f8839a9ba572a35cbb80 (patch) | |
tree | 780093381841fcccbed8138d5a8fe1cc99923c03 /toxcore/onion_announce.c | |
parent | 819fe534ea62b07340b20f18841d1ed93cf5caff (diff) |
Use named types for onion callbacks.
This is now a style rule: you can only use typedef'd function types.
Previous rules now applied in `onion_*.c`:
* `struct`s must have a name (typedef of unnamed struct is not allowed).
* `++i` for increment-stmt, not `i++`, e.g. in loops.
* Only a single declarator per struct member declaration.
* Type_Names vs. variable_names.
Diffstat (limited to 'toxcore/onion_announce.c')
-rw-r--r-- | toxcore/onion_announce.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/toxcore/onion_announce.c b/toxcore/onion_announce.c index 6c9e8659..8f122fe6 100644 --- a/toxcore/onion_announce.c +++ b/toxcore/onion_announce.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #define DATA_REQUEST_MIN_SIZE ONION_DATA_REQUEST_MIN_SIZE | 40 | #define DATA_REQUEST_MIN_SIZE ONION_DATA_REQUEST_MIN_SIZE |
41 | #define DATA_REQUEST_MIN_SIZE_RECV (DATA_REQUEST_MIN_SIZE + ONION_RETURN_3) | 41 | #define DATA_REQUEST_MIN_SIZE_RECV (DATA_REQUEST_MIN_SIZE + ONION_RETURN_3) |
42 | 42 | ||
43 | typedef struct { | 43 | typedef struct Onion_Announce_Entry { |
44 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; | 44 | uint8_t public_key[CRYPTO_PUBLIC_KEY_SIZE]; |
45 | IP_Port ret_ip_port; | 45 | IP_Port ret_ip_port; |
46 | uint8_t ret[ONION_RETURN_3]; | 46 | uint8_t ret[ONION_RETURN_3]; |
@@ -264,7 +264,7 @@ static int in_entries(const Onion_Announce *onion_a, const uint8_t *public_key) | |||
264 | return -1; | 264 | return -1; |
265 | } | 265 | } |
266 | 266 | ||
267 | typedef struct { | 267 | typedef struct Cmp_data { |
268 | const uint8_t *base_public_key; | 268 | const uint8_t *base_public_key; |
269 | Onion_Announce_Entry entry; | 269 | Onion_Announce_Entry entry; |
270 | } Cmp_data; | 270 | } Cmp_data; |
@@ -312,14 +312,14 @@ static void sort_onion_announce_list(Onion_Announce_Entry *list, unsigned int le | |||
312 | // comparison function can use it as the base of comparison. | 312 | // comparison function can use it as the base of comparison. |
313 | VLA(Cmp_data, cmp_list, length); | 313 | VLA(Cmp_data, cmp_list, length); |
314 | 314 | ||
315 | for (uint32_t i = 0; i < length; i++) { | 315 | for (uint32_t i = 0; i < length; ++i) { |
316 | cmp_list[i].base_public_key = comp_public_key; | 316 | cmp_list[i].base_public_key = comp_public_key; |
317 | cmp_list[i].entry = list[i]; | 317 | cmp_list[i].entry = list[i]; |
318 | } | 318 | } |
319 | 319 | ||
320 | qsort(cmp_list, length, sizeof(Cmp_data), cmp_entry); | 320 | qsort(cmp_list, length, sizeof(Cmp_data), cmp_entry); |
321 | 321 | ||
322 | for (uint32_t i = 0; i < length; i++) { | 322 | for (uint32_t i = 0; i < length; ++i) { |
323 | list[i] = cmp_list[i].entry; | 323 | list[i] = cmp_list[i].entry; |
324 | } | 324 | } |
325 | } | 325 | } |