mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fix some compiler warnings.
This commit is contained in:
parent
390fcb6c27
commit
6935643f9a
|
@ -91,7 +91,7 @@ START_TEST(test_basic)
|
|||
uint8_t r_req[2 + 1 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES];
|
||||
uint16_t size = 1 + crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES;
|
||||
size = htons(size);
|
||||
ret = encrypt_data_symmetric(f_shared_key, f_nonce, r_req_p, 1 + crypto_box_PUBLICKEYBYTES, r_req + 2);
|
||||
encrypt_data_symmetric(f_shared_key, f_nonce, r_req_p, 1 + crypto_box_PUBLICKEYBYTES, r_req + 2);
|
||||
increment_nonce(f_nonce);
|
||||
memcpy(r_req, &size, 2);
|
||||
uint32_t i;
|
||||
|
@ -587,7 +587,7 @@ START_TEST(test_tcp_connection)
|
|||
do_tcp_connections(tc_1, NULL);
|
||||
do_tcp_connections(tc_2, NULL);
|
||||
|
||||
int ret = send_packet_tcp_connection(tc_1, 0, "Gentoo", 6);
|
||||
int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6);
|
||||
ck_assert_msg(ret == 0, "could not send packet.");
|
||||
set_packet_tcp_connection_callback(tc_2, &tcp_data_callback, (void *) 120397);
|
||||
|
||||
|
@ -608,7 +608,7 @@ START_TEST(test_tcp_connection)
|
|||
do_tcp_connections(tc_1, NULL);
|
||||
do_tcp_connections(tc_2, NULL);
|
||||
|
||||
ck_assert_msg(send_packet_tcp_connection(tc_1, 0, "Gentoo", 6) == -1, "could send packet.");
|
||||
ck_assert_msg(send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6) == -1, "could send packet.");
|
||||
ck_assert_msg(kill_tcp_connection_to(tc_2, 0) == 0, "could not kill connection to\n");
|
||||
|
||||
kill_TCP_server(tcp_s);
|
||||
|
@ -684,7 +684,7 @@ START_TEST(test_tcp_connection2)
|
|||
do_tcp_connections(tc_1, NULL);
|
||||
do_tcp_connections(tc_2, NULL);
|
||||
|
||||
int ret = send_packet_tcp_connection(tc_1, 0, "Gentoo", 6);
|
||||
int ret = send_packet_tcp_connection(tc_1, 0, (const uint8_t *)"Gentoo", 6);
|
||||
ck_assert_msg(ret == 0, "could not send packet.");
|
||||
set_oob_packet_tcp_connection_callback(tc_2, &tcp_oobdata_callback, tc_2);
|
||||
set_packet_tcp_connection_callback(tc_1, &tcp_data_callback, (void *) 120397);
|
||||
|
|
|
@ -79,7 +79,6 @@ START_TEST(test_fillup)
|
|||
IPPTs ippts_send;
|
||||
IP_Port ipp_recv;
|
||||
};
|
||||
unsigned int fail = 0;
|
||||
struct entry entries[128];
|
||||
struct entry closest[8];
|
||||
|
||||
|
|
|
@ -284,7 +284,9 @@ void test_addto_lists_good(DHT *dht,
|
|||
ck_assert_msg(client_in_list(list, length, public_key) == -1, "Good client id is in the list");
|
||||
}
|
||||
|
||||
void test_addto_lists(IP ip)
|
||||
// These tests currently fail.
|
||||
#if 0
|
||||
static void test_addto_lists(IP ip)
|
||||
{
|
||||
Networking_Core *net = new_networking(ip, TOX_PORT_DEFAULT);
|
||||
ck_assert_msg(net != 0, "Failed to create Networking_Core");
|
||||
|
@ -353,7 +355,6 @@ START_TEST(test_addto_lists_ipv4)
|
|||
IP ip;
|
||||
ip_init(&ip, 0);
|
||||
test_addto_lists(ip);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
@ -362,9 +363,9 @@ START_TEST(test_addto_lists_ipv6)
|
|||
IP ip;
|
||||
ip_init(&ip, 1);
|
||||
test_addto_lists(ip);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
#endif
|
||||
|
||||
#define DHT_DEFAULT_PORT (TOX_PORT_DEFAULT + 20)
|
||||
|
||||
|
@ -575,10 +576,6 @@ START_TEST(test_DHT_test)
|
|||
uint16_t tox2;
|
||||
} pairs[NUM_DHT_FRIENDS];
|
||||
|
||||
uint8_t address[TOX_ADDRESS_SIZE];
|
||||
|
||||
unsigned int num_f = 0;
|
||||
|
||||
for (i = 0; i < NUM_DHT_FRIENDS; ++i) {
|
||||
loop_top:
|
||||
pairs[i].tox1 = rand() % NUM_DHT;
|
||||
|
@ -637,8 +634,10 @@ Suite *dht_suite(void)
|
|||
{
|
||||
Suite *s = suite_create("DHT");
|
||||
|
||||
//DEFTESTCASE(addto_lists_ipv4);
|
||||
//DEFTESTCASE(addto_lists_ipv6);
|
||||
#if 0
|
||||
DEFTESTCASE(addto_lists_ipv4);
|
||||
DEFTESTCASE(addto_lists_ipv6);
|
||||
#endif
|
||||
DEFTESTCASE_SLOW(list, 20);
|
||||
DEFTESTCASE_SLOW(DHT_test, 50);
|
||||
return s;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
unsigned char salt[32] = {0xB1, 0xC2, 0x09, 0xEE, 0x50, 0x6C, 0xF0, 0x20, 0xC4, 0xD6, 0xEB, 0xC0, 0x44, 0x51, 0x3B, 0x60, 0x4B, 0x39, 0x4A, 0xCF, 0x09, 0x53, 0x4F, 0xEA, 0x08, 0x41, 0xFA, 0xCA, 0x66, 0xD2, 0x68, 0x7F};
|
||||
unsigned char known_key[crypto_box_BEFORENMBYTES] = {0x29, 0x36, 0x1c, 0x9e, 0x65, 0xbb, 0x46, 0x8b, 0xde, 0xa1, 0xac, 0xf, 0xd5, 0x11, 0x81, 0xc8, 0x29, 0x28, 0x17, 0x23, 0xa6, 0xc3, 0x6b, 0x77, 0x2e, 0xd7, 0xd3, 0x10, 0xeb, 0xd2, 0xf7, 0xc8};
|
||||
char *pw = "hunter2";
|
||||
const char *pw = "hunter2";
|
||||
unsigned int pwlen = 7;
|
||||
|
||||
unsigned char known_key2[crypto_box_BEFORENMBYTES] = {0x7a, 0xfa, 0x95, 0x45, 0x36, 0x8a, 0xa2, 0x5c, 0x40, 0xfd, 0xc0, 0xe2, 0x35, 0x8, 0x7, 0x88, 0xfa, 0xf9, 0x37, 0x86, 0xeb, 0xff, 0x50, 0x4f, 0x3, 0xe2, 0xf6, 0xd9, 0xef, 0x9, 0x17, 0x1};
|
||||
|
@ -71,7 +71,7 @@ START_TEST(test_save_friend)
|
|||
size_t size2 = size + TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
|
||||
uint8_t enc_data[size2];
|
||||
TOX_ERR_ENCRYPTION error1;
|
||||
bool ret = tox_pass_encrypt(data, size, "correcthorsebatterystaple", 25, enc_data, &error1);
|
||||
bool ret = tox_pass_encrypt(data, size, (const uint8_t *)"correcthorsebatterystaple", 25, enc_data, &error1);
|
||||
ck_assert_msg(ret, "failed to encrypted save: %u", error1);
|
||||
ck_assert_msg(tox_is_data_encrypted(enc_data), "magic number missing");
|
||||
|
||||
|
@ -85,9 +85,10 @@ START_TEST(test_save_friend)
|
|||
Tox *tox3 = tox_new(&options, &err2);
|
||||
ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %u. should fail with %u", err2,
|
||||
TOX_ERR_NEW_LOAD_ENCRYPTED);
|
||||
ck_assert_msg(tox3 == NULL, "tox_new with error should return NULL");
|
||||
uint8_t dec_data[size];
|
||||
TOX_ERR_DECRYPTION err3;
|
||||
ret = tox_pass_decrypt(enc_data, size2, "correcthorsebatterystaple", 25, dec_data, &err3);
|
||||
ret = tox_pass_decrypt(enc_data, size2, (const uint8_t *)"correcthorsebatterystaple", 25, dec_data, &err3);
|
||||
ck_assert_msg(ret, "failed to decrypt save: %u", err3);
|
||||
options.savedata_data = dec_data;
|
||||
options.savedata_length = size;
|
||||
|
@ -111,7 +112,7 @@ START_TEST(test_save_friend)
|
|||
ck_assert_msg(tox_is_data_encrypted(encdata2), "magic number the second missing");
|
||||
|
||||
uint8_t out1[size], out2[size];
|
||||
ret = tox_pass_decrypt(encdata2, size2, pw, pwlen, out1, &err3);
|
||||
ret = tox_pass_decrypt(encdata2, size2, (const uint8_t *)pw, pwlen, out1, &err3);
|
||||
ck_assert_msg(ret, "failed to pw decrypt %u", err3);
|
||||
ret = tox_pass_key_decrypt(encdata2, size2, &key, out2, &err3);
|
||||
ck_assert_msg(ret, "failed to key decrypt %u", err3);
|
||||
|
@ -141,16 +142,16 @@ START_TEST(test_keys)
|
|||
TOX_ERR_DECRYPTION decerr;
|
||||
TOX_ERR_KEY_DERIVATION keyerr;
|
||||
TOX_PASS_KEY key;
|
||||
bool ret = tox_derive_key_from_pass("123qweasdzxc", 12, &key, &keyerr);
|
||||
bool ret = tox_derive_key_from_pass((const uint8_t *)"123qweasdzxc", 12, &key, &keyerr);
|
||||
ck_assert_msg(ret, "generic failure 1: %u", keyerr);
|
||||
uint8_t *string = "No Patrick, mayonnaise is not an instrument."; // 44
|
||||
const uint8_t *string = (const uint8_t *)"No Patrick, mayonnaise is not an instrument."; // 44
|
||||
|
||||
uint8_t encrypted[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
ret = tox_pass_key_encrypt(string, 44, &key, encrypted, &encerr);
|
||||
ck_assert_msg(ret, "generic failure 2: %u", encerr);
|
||||
|
||||
uint8_t encrypted2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
ret = tox_pass_encrypt(string, 44, "123qweasdzxc", 12, encrypted2, &encerr);
|
||||
ret = tox_pass_encrypt(string, 44, (const uint8_t *)"123qweasdzxc", 12, encrypted2, &encerr);
|
||||
ck_assert_msg(ret, "generic failure 3: %u", encerr);
|
||||
|
||||
uint8_t out1[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
|
@ -160,7 +161,8 @@ START_TEST(test_keys)
|
|||
ck_assert_msg(ret, "generic failure 4: %u", decerr);
|
||||
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 1 failed");
|
||||
|
||||
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, "123qweasdzxc", 12, out2, &decerr);
|
||||
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)"123qweasdzxc", 12, out2,
|
||||
&decerr);
|
||||
ck_assert_msg(ret, "generic failure 5: %u", decerr);
|
||||
ck_assert_msg(memcmp(out2, string, 44) == 0, "decryption 2 failed");
|
||||
|
||||
|
@ -169,14 +171,15 @@ START_TEST(test_keys)
|
|||
ck_assert_msg(decerr != TOX_ERR_DECRYPTION_FAILED, "Bad error code %u", decerr);
|
||||
|
||||
// test that pass_decrypt can decrypt things from pass_key_encrypt
|
||||
ret = tox_pass_decrypt(encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, "123qweasdzxc", 12, out1, &decerr);
|
||||
ret = tox_pass_decrypt(encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)"123qweasdzxc", 12, out1,
|
||||
&decerr);
|
||||
ck_assert_msg(ret, "generic failure 6: %u", decerr);
|
||||
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 3 failed");
|
||||
|
||||
uint8_t salt[TOX_PASS_SALT_LENGTH];
|
||||
ck_assert_msg(tox_get_salt(encrypted, salt), "couldn't get salt");
|
||||
TOX_PASS_KEY key2;
|
||||
ret = tox_derive_key_with_salt("123qweasdzxc", 12, salt, &key2, &keyerr);
|
||||
ret = tox_derive_key_with_salt((const uint8_t *)"123qweasdzxc", 12, salt, &key2, &keyerr);
|
||||
ck_assert_msg(ret, "generic failure 7: %u", keyerr);
|
||||
ck_assert_msg(0 == memcmp(&key, &key2, sizeof(TOX_PASS_KEY)), "salt comparison failed");
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ Onions *new_onions(uint16_t port)
|
|||
DHT *dht = new_DHT(new_networking(ip, port));
|
||||
on->onion = new_onion(dht);
|
||||
on->onion_a = new_onion_announce(dht);
|
||||
TCP_Proxy_Info inf = {0};
|
||||
TCP_Proxy_Info inf = {{{0}}};
|
||||
on->onion_c = new_onion_client(new_net_crypto(dht, &inf));
|
||||
|
||||
if (on->onion && on->onion_a && on->onion_c)
|
||||
|
@ -418,8 +418,6 @@ START_TEST(test_announce)
|
|||
onion_dht_pk_callback(onions[NUM_FIRST]->onion_c, frnum_f, &dht_pk_callback, onions[NUM_FIRST], NUM_FIRST);
|
||||
onion_dht_pk_callback(onions[NUM_LAST]->onion_c, frnum, &dht_pk_callback, onions[NUM_LAST], NUM_LAST);
|
||||
|
||||
int ok = -1;
|
||||
|
||||
IP_Port ip_port;
|
||||
|
||||
while (!first || !last) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
@ -709,11 +710,7 @@ START_TEST(test_few_clients)
|
|||
uint32_t tox2_interval = tox_iteration_interval(tox2);
|
||||
uint32_t tox3_interval = tox_iteration_interval(tox3);
|
||||
|
||||
if (tox2_interval > tox3_interval) {
|
||||
c_sleep(tox3_interval);
|
||||
} else {
|
||||
c_sleep(tox2_interval);
|
||||
}
|
||||
c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval)));
|
||||
}
|
||||
|
||||
printf("100MB file sent in %llu seconds\n", time(NULL) - f_time);
|
||||
|
@ -721,7 +718,6 @@ START_TEST(test_few_clients)
|
|||
printf("Starting file streaming transfer test.\n");
|
||||
|
||||
file_sending_done = file_accepted = file_size = file_recv = sendf_ok = size_recv = 0;
|
||||
f_time = time(NULL);
|
||||
tox_callback_file_recv_chunk(tox3, write_file, &to_compare);
|
||||
tox_callback_file_recv_control(tox2, file_print_control, &to_compare);
|
||||
tox_callback_file_chunk_request(tox2, tox_file_chunk_request, &to_compare);
|
||||
|
@ -762,17 +758,12 @@ START_TEST(test_few_clients)
|
|||
uint32_t tox2_interval = tox_iteration_interval(tox2);
|
||||
uint32_t tox3_interval = tox_iteration_interval(tox3);
|
||||
|
||||
if (tox2_interval > tox3_interval) {
|
||||
c_sleep(tox3_interval);
|
||||
} else {
|
||||
c_sleep(tox2_interval);
|
||||
}
|
||||
c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval)));
|
||||
}
|
||||
|
||||
printf("Starting file 0 transfer test.\n");
|
||||
|
||||
file_sending_done = file_accepted = file_size = file_recv = sendf_ok = size_recv = 0;
|
||||
f_time = time(NULL);
|
||||
tox_callback_file_recv_chunk(tox3, write_file, &to_compare);
|
||||
tox_callback_file_recv_control(tox2, file_print_control, &to_compare);
|
||||
tox_callback_file_chunk_request(tox2, tox_file_chunk_request, &to_compare);
|
||||
|
@ -810,11 +801,7 @@ START_TEST(test_few_clients)
|
|||
uint32_t tox2_interval = tox_iteration_interval(tox2);
|
||||
uint32_t tox3_interval = tox_iteration_interval(tox3);
|
||||
|
||||
if (tox2_interval > tox3_interval) {
|
||||
c_sleep(tox3_interval);
|
||||
} else {
|
||||
c_sleep(tox2_interval);
|
||||
}
|
||||
c_sleep(MIN(tox1_interval, MIN(tox2_interval, tox3_interval)));
|
||||
}
|
||||
|
||||
printf("test_few_clients succeeded, took %llu seconds\n", time(NULL) - cur_time);
|
||||
|
@ -988,7 +975,7 @@ loop_top:
|
|||
}
|
||||
|
||||
while (1) {
|
||||
uint16_t counter = 0, cc = 0;
|
||||
uint16_t counter = 0;
|
||||
|
||||
for (i = 0; i < NUM_TOXES_TCP; ++i) {
|
||||
for (j = 0; j < tox_self_get_friend_list_size(toxes[i]); ++j)
|
||||
|
@ -1216,7 +1203,8 @@ group_test_restart:
|
|||
|
||||
ck_assert_msg(tox_add_groupchat(toxes[0]) != -1, "Failed to create group");
|
||||
ck_assert_msg(tox_invite_friend(toxes[0], 0, 0) == 0, "Failed to invite friend");
|
||||
ck_assert_msg(tox_group_set_title(toxes[0], 0, "Gentoo", sizeof("Gentoo") - 1) == 0, "Failed to set group title");
|
||||
ck_assert_msg(tox_group_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1) == 0,
|
||||
"Failed to set group title");
|
||||
invite_counter = ~0;
|
||||
|
||||
unsigned int done = ~0;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
// system provided
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// C
|
||||
|
|
|
@ -188,7 +188,7 @@ void send_irc_group(Tox *tox, uint8_t *msg, uint16_t len)
|
|||
if (pmsg == NULL)
|
||||
return;
|
||||
|
||||
uint8_t *dt = req;
|
||||
uint8_t *dt;
|
||||
|
||||
for (dt = req, i = 0; dt != pmsg && *dt != '!'; ++dt, ++i) {
|
||||
message[i] = *dt;
|
||||
|
|
|
@ -80,6 +80,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (ret == -1) {
|
||||
printf("fork failed\n");
|
||||
free(master);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef AUDIO_H
|
||||
#define AUDIO_H
|
||||
|
||||
#include <opus/opus.h>
|
||||
#include <opus.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "toxav.h"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
/* Audio encoding/decoding */
|
||||
#include <opus/opus.h>
|
||||
#include <opus.h>
|
||||
|
||||
#include "../toxcore/group.h"
|
||||
|
||||
|
|
|
@ -382,7 +382,8 @@ NEW_MULTIPARTED:
|
|||
session->mp = new_message(ntohs(header->tlen) + sizeof(struct RTPHeader), data, length);
|
||||
|
||||
/* Reposition data if necessary */
|
||||
if (ntohs(header->cpart));
|
||||
if (ntohs(header->cpart))
|
||||
;
|
||||
|
||||
memmove(session->mp->data + ntohs(header->cpart), session->mp->data, session->mp->len);
|
||||
}
|
||||
|
|
|
@ -776,7 +776,7 @@ static int handle_tcp_onion(void *object, const uint8_t *data, uint16_t length,
|
|||
if (length == 0)
|
||||
return 1;
|
||||
|
||||
IP_Port ip_port = {0};
|
||||
IP_Port ip_port = {{0}};
|
||||
ip_port.ip.family = TCP_FAMILY;
|
||||
|
||||
if (data[0] == NET_PACKET_ANNOUNCE_RESPONSE) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user