diff options
author | iphydf <iphydf@users.noreply.github.com> | 2020-05-02 00:34:13 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2020-05-02 22:00:09 +0100 |
commit | f8ab32aaa4efce2c9a310a14d10b19fb8544cfd9 (patch) | |
tree | 4dbc49882d6af0954c533b2482b2100d312d2bc7 /toxcore | |
parent | 2570ddcb17fdf5bea56c6bc1c5c2d04ba2068ee7 (diff) |
Add a check that we don't have any unused functions.
This check puts all of our code in a C++ anonymous namespace, which is
effectively making all functions `static`. This allows the compiler to
determine that a function is unused, so we can delete it.
Diffstat (limited to 'toxcore')
-rw-r--r-- | toxcore/LAN_discovery.api.h | 2 | ||||
-rw-r--r-- | toxcore/LAN_discovery.h | 2 | ||||
-rw-r--r-- | toxcore/Messenger.c | 32 | ||||
-rw-r--r-- | toxcore/Messenger.h | 9 | ||||
-rw-r--r-- | toxcore/crypto_core.c | 3 | ||||
-rw-r--r-- | toxcore/group.c | 30 | ||||
-rw-r--r-- | toxcore/group.h | 13 | ||||
-rw-r--r-- | toxcore/list.c | 10 | ||||
-rw-r--r-- | toxcore/list.h | 8 |
9 files changed, 3 insertions, 106 deletions
diff --git a/toxcore/LAN_discovery.api.h b/toxcore/LAN_discovery.api.h index 5c25b67b..ad3d60ed 100644 --- a/toxcore/LAN_discovery.api.h +++ b/toxcore/LAN_discovery.api.h | |||
@@ -21,7 +21,7 @@ namespace lan_discovery { | |||
21 | /** | 21 | /** |
22 | * Interval in seconds between LAN discovery packet sending. | 22 | * Interval in seconds between LAN discovery packet sending. |
23 | */ | 23 | */ |
24 | const INTERVAL = 10; | 24 | #define LAN_DISCOVERY_INTERVAL 10 |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * Send a LAN discovery pcaket to the broadcast address with port port. | 27 | * Send a LAN discovery pcaket to the broadcast address with port port. |
diff --git a/toxcore/LAN_discovery.h b/toxcore/LAN_discovery.h index 7e049b99..6b55e319 100644 --- a/toxcore/LAN_discovery.h +++ b/toxcore/LAN_discovery.h | |||
@@ -26,8 +26,6 @@ typedef struct IP IP; | |||
26 | */ | 26 | */ |
27 | #define LAN_DISCOVERY_INTERVAL 10 | 27 | #define LAN_DISCOVERY_INTERVAL 10 |
28 | 28 | ||
29 | uint32_t lan_discovery_interval(void); | ||
30 | |||
31 | /** | 29 | /** |
32 | * Send a LAN discovery pcaket to the broadcast address with port port. | 30 | * Send a LAN discovery pcaket to the broadcast address with port port. |
33 | */ | 31 | */ |
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 82c31147..556acc27 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1450,38 +1450,6 @@ int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin | |||
1450 | return -6; | 1450 | return -6; |
1451 | } | 1451 | } |
1452 | 1452 | ||
1453 | /* Give the number of bytes left to be sent/received. | ||
1454 | * | ||
1455 | * send_receive is 0 if we want the sending files, 1 if we want the receiving. | ||
1456 | * | ||
1457 | * return number of bytes remaining to be sent/received on success | ||
1458 | * return 0 on failure | ||
1459 | */ | ||
1460 | uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive) | ||
1461 | { | ||
1462 | if (!friend_is_valid(m, friendnumber)) { | ||
1463 | return 0; | ||
1464 | } | ||
1465 | |||
1466 | const struct File_Transfers *const sending = &m->friendlist[friendnumber].file_sending[filenumber]; | ||
1467 | |||
1468 | if (send_receive == 0) { | ||
1469 | if (sending->status == FILESTATUS_NONE) { | ||
1470 | return 0; | ||
1471 | } | ||
1472 | |||
1473 | return sending->size - sending->transferred; | ||
1474 | } | ||
1475 | |||
1476 | const struct File_Transfers *const receiving = &m->friendlist[friendnumber].file_receiving[filenumber]; | ||
1477 | |||
1478 | if (receiving->status == FILESTATUS_NONE) { | ||
1479 | return 0; | ||
1480 | } | ||
1481 | |||
1482 | return receiving->size - receiving->transferred; | ||
1483 | } | ||
1484 | |||
1485 | /** | 1453 | /** |
1486 | * Iterate over all file transfers and request chunks (from the client) for each | 1454 | * Iterate over all file transfers and request chunks (from the client) for each |
1487 | * of them. | 1455 | * of them. |
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index 74c19e09..31526b63 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h | |||
@@ -651,15 +651,6 @@ int file_seek(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin | |||
651 | int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data, | 651 | int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data, |
652 | uint16_t length); | 652 | uint16_t length); |
653 | 653 | ||
654 | /* Give the number of bytes left to be sent/received. | ||
655 | * | ||
656 | * send_receive is 0 if we want the sending files, 1 if we want the receiving. | ||
657 | * | ||
658 | * return number of bytes remaining to be sent/received on success | ||
659 | * return 0 on failure | ||
660 | */ | ||
661 | uint64_t file_dataremaining(const Messenger *m, int32_t friendnumber, uint8_t filenumber, uint8_t send_receive); | ||
662 | |||
663 | /** A/V related */ | 654 | /** A/V related */ |
664 | 655 | ||
665 | /* Set the callback for msi packets. | 656 | /* Set the callback for msi packets. |
diff --git a/toxcore/crypto_core.c b/toxcore/crypto_core.c index 403e0872..2fa4750f 100644 --- a/toxcore/crypto_core.c +++ b/toxcore/crypto_core.c | |||
@@ -12,11 +12,12 @@ | |||
12 | #include "config.h" | 12 | #include "config.h" |
13 | #endif | 13 | #endif |
14 | 14 | ||
15 | #include "crypto_core.h" | ||
16 | |||
15 | #include <stdlib.h> | 17 | #include <stdlib.h> |
16 | #include <string.h> | 18 | #include <string.h> |
17 | 19 | ||
18 | #include "ccompat.h" | 20 | #include "ccompat.h" |
19 | #include "crypto_core.h" | ||
20 | 21 | ||
21 | #ifndef VANILLA_NACL | 22 | #ifndef VANILLA_NACL |
22 | /* We use libsodium by default. */ | 23 | /* We use libsodium by default. */ |
diff --git a/toxcore/group.c b/toxcore/group.c index 3e04f181..a946e7b8 100644 --- a/toxcore/group.c +++ b/toxcore/group.c | |||
@@ -1301,36 +1301,6 @@ int group_set_max_frozen(const Group_Chats *g_c, uint32_t groupnumber, uint32_t | |||
1301 | return 0; | 1301 | return 0; |
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | /* List all the (frozen, if frozen is true) peers in the group chat. | ||
1305 | * | ||
1306 | * Copies the names of the peers to the `name[length][MAX_NAME_LENGTH]` array. | ||
1307 | * | ||
1308 | * Copies the lengths of the names to `lengths[length]` | ||
1309 | * | ||
1310 | * returns the number of peers on success. | ||
1311 | * | ||
1312 | * return -1 on failure. | ||
1313 | */ | ||
1314 | int group_names(const Group_Chats *g_c, uint32_t groupnumber, uint8_t names[][MAX_NAME_LENGTH], uint16_t lengths[], | ||
1315 | uint16_t length, bool frozen) | ||
1316 | { | ||
1317 | const Group_c *g = get_group_c(g_c, groupnumber); | ||
1318 | |||
1319 | if (!g) { | ||
1320 | return -1; | ||
1321 | } | ||
1322 | |||
1323 | const uint32_t num = frozen ? g->numfrozen : g->numpeers; | ||
1324 | |||
1325 | unsigned int i; | ||
1326 | |||
1327 | for (i = 0; i < num && i < length; ++i) { | ||
1328 | lengths[i] = group_peername(g_c, groupnumber, i, names[i], frozen); | ||
1329 | } | ||
1330 | |||
1331 | return i; | ||
1332 | } | ||
1333 | |||
1334 | /* Return the number of (frozen, if frozen is true) peers in the group chat on | 1304 | /* Return the number of (frozen, if frozen is true) peers in the group chat on |
1335 | * success. | 1305 | * success. |
1336 | * return -1 if groupnumber is invalid. | 1306 | * return -1 if groupnumber is invalid. |
diff --git a/toxcore/group.h b/toxcore/group.h index 1e054de3..eb8db55f 100644 --- a/toxcore/group.h +++ b/toxcore/group.h | |||
@@ -355,19 +355,6 @@ int group_number_peers(const Group_Chats *g_c, uint32_t groupnumber, bool frozen | |||
355 | */ | 355 | */ |
356 | int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber); | 356 | int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber); |
357 | 357 | ||
358 | /* List all the (frozen, if frozen is true) peers in the group chat. | ||
359 | * | ||
360 | * Copies the names of the peers to the `name[length][MAX_NAME_LENGTH]` array. | ||
361 | * | ||
362 | * Copies the lengths of the names to `lengths[length]` | ||
363 | * | ||
364 | * returns the number of peers on success. | ||
365 | * | ||
366 | * return -1 on failure. | ||
367 | */ | ||
368 | int group_names(const Group_Chats *g_c, uint32_t groupnumber, uint8_t names[][MAX_NAME_LENGTH], uint16_t lengths[], | ||
369 | uint16_t length, bool frozen); | ||
370 | |||
371 | /* Set handlers for custom lossy packets. */ | 358 | /* Set handlers for custom lossy packets. */ |
372 | void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, lossy_packet_cb *function); | 359 | void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, lossy_packet_cb *function); |
373 | 360 | ||
diff --git a/toxcore/list.c b/toxcore/list.c index cb3c71cc..fca8cea8 100644 --- a/toxcore/list.c +++ b/toxcore/list.c | |||
@@ -248,13 +248,3 @@ int bs_list_remove(BS_List *list, const uint8_t *data, int id) | |||
248 | 248 | ||
249 | return 1; | 249 | return 1; |
250 | } | 250 | } |
251 | |||
252 | int bs_list_trim(BS_List *list) | ||
253 | { | ||
254 | if (!resize(list, list->n)) { | ||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | list->capacity = list->n; | ||
259 | return 1; | ||
260 | } | ||
diff --git a/toxcore/list.h b/toxcore/list.h index 9d65b53f..afe4240b 100644 --- a/toxcore/list.h +++ b/toxcore/list.h | |||
@@ -57,12 +57,4 @@ int bs_list_add(BS_List *list, const uint8_t *data, int id); | |||
57 | */ | 57 | */ |
58 | int bs_list_remove(BS_List *list, const uint8_t *data, int id); | 58 | int bs_list_remove(BS_List *list, const uint8_t *data, int id); |
59 | 59 | ||
60 | /* Removes the memory overhead | ||
61 | * | ||
62 | * return value: | ||
63 | * 1 : success | ||
64 | * 0 : failure | ||
65 | */ | ||
66 | int bs_list_trim(BS_List *list); | ||
67 | |||
68 | #endif | 60 | #endif |