Wrong use of unsigned integer.

This commit is contained in:
hugbubby 2018-07-15 18:12:16 -07:00
parent 864d1c15e4
commit a592f0fa87
3 changed files with 18 additions and 18 deletions

View File

@ -68,7 +68,7 @@ static void handle_conference_invite(
if (tox_self_get_friend_list_size(tox) > 1) {
printf("tox #%d: inviting next friend\n", id);
ck_assert_msg(tox_conference_invite(tox, 1, g_num, nullptr) != 0, "Failed to invite friend");
ck_assert_msg(tox_conference_invite(tox, 1, g_num, nullptr) != 0, "failed to invite friend");
} else {
printf("tox #%d was the last tox, no further invites happening\n", id);
}
@ -95,9 +95,9 @@ static void run_conference_tests(Tox **toxes, uint32_t *tox_index)
ck_assert_msg(
tox_conference_send_message(
toxes[random_u32() % NUM_GROUP_TOX], 0, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)GROUP_MESSAGE,
sizeof(GROUP_MESSAGE) - 1, &err) != 0, "Failed to send group message.");
sizeof(GROUP_MESSAGE) - 1, &err) != 0, "failed to send group message");
ck_assert_msg(
err == TOX_ERR_CONFERENCE_SEND_MESSAGE_OK, "Failed to send group message.");
err == TOX_ERR_CONFERENCE_SEND_MESSAGE_OK, "failed to send group message");
num_recv = 0;
for (uint8_t j = 0; j < 20; ++j) {
@ -109,7 +109,7 @@ static void run_conference_tests(Tox **toxes, uint32_t *tox_index)
}
c_sleep(25);
ck_assert_msg(num_recv == NUM_GROUP_TOX, "Failed to recv group messages.");
ck_assert_msg(num_recv == NUM_GROUP_TOX, "failed to recv group messages");
for (uint16_t k = NUM_GROUP_TOX; k != 0 ; --k) {
tox_conference_delete(toxes[k - 1], 0, nullptr);
@ -149,7 +149,7 @@ static void test_many_group(void)
tox_index[i] = i + 1;
toxes[i] = tox_new_log(opts, &err, &tox_index[i]);
ck_assert_msg(toxes[i] != nullptr, "Failed to create tox instance %u: error %d", i, err);
ck_assert_msg(toxes[i] != nullptr, "failed to create tox instance %u: error %d", i, err);
tox_callback_self_connection_status(toxes[i], &handle_self_connection_status);
tox_callback_friend_connection_status(toxes[i], &handle_friend_connection_status);
tox_callback_conference_invite(toxes[i], &handle_conference_invite);
@ -173,11 +173,11 @@ static void test_many_group(void)
tox_self_get_public_key(toxes[i - 1], key);
tox_friend_add_norequest(toxes[i], key, &err);
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "Failed to add friend: error %d", err);
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "failed to add friend: error %d", err);
tox_self_get_public_key(toxes[i], key);
tox_friend_add_norequest(toxes[i - 1], key, &err);
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "Failed to add friend: error %d", err);
ck_assert_msg(err == TOX_ERR_FRIEND_ADD_OK, "failed to add friend: error %d", err);
}
printf("waiting for everyone to come online\n");
@ -197,13 +197,13 @@ static void test_many_group(void)
c_sleep(1000);
}
printf("friends connected, took %d seconds\n", (uint16_t)(time(nullptr) - cur_time));
printf("friends connected, took %d seconds\n", (int)(time(nullptr) - cur_time));
ck_assert_msg(tox_conference_new(toxes[0], nullptr) != UINT32_MAX, "Failed to create group");
ck_assert_msg(tox_conference_new(toxes[0], nullptr) != UINT32_MAX, "failed to create group");
printf("tox #%d: inviting its first friend\n", tox_index[0]);
ck_assert_msg(tox_conference_invite(toxes[0], 0, 0, nullptr) != 0, "Failed to invite friend");
ck_assert_msg(tox_conference_invite(toxes[0], 0, 0, nullptr) != 0, "failed to invite friend");
ck_assert_msg(tox_conference_set_title(toxes[0], 0, (const uint8_t *)"Gentoo", sizeof("Gentoo") - 1, nullptr) != 0,
"Failed to set group title");
"failed to set group title");
// One iteration for all the invitations to happen.
for (uint16_t i = 0; i < NUM_GROUP_TOX; ++i) {
@ -250,7 +250,7 @@ static void test_many_group(void)
ck_assert_msg(memcmp("Gentoo", title, ret) == 0, "Wrong title");
}
printf("group connected, took %d seconds\n", (uint16_t)(time(nullptr) - cur_time));
printf("group connected, took %d seconds\n", (int)(time(nullptr) - cur_time));
run_conference_tests(toxes, tox_index);
@ -260,7 +260,7 @@ static void test_many_group(void)
tox_kill(toxes[i]);
}
printf("test_many_group succeeded, took %d seconds\n", (uint16_t)(time(nullptr) - test_start_time));
printf("test_many_group succeeded, took %d seconds\n", (int)(time(nullptr) - test_start_time));
}
int main(void)

View File

@ -14,15 +14,15 @@
int main(void)
{
// Create toxes.
uint8_t id = 1;
uint32_t id = 1;
Tox *tox1 = tox_new_log(nullptr, nullptr, &id);
// Create two conferences and then exit.
TOX_ERR_CONFERENCE_NEW err;
tox_conference_new(tox1, &err);
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "Failed to create conference 1: %d.", err);
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 1: %d", err);
tox_conference_new(tox1, &err);
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "Failed to create conference 2: %d.", err);
ck_assert_msg(err == TOX_ERR_CONFERENCE_NEW_OK, "failed to create conference 2: %d", err);
tox_kill(tox1);

View File

@ -96,7 +96,7 @@ static int client_in_list(Client_data *list, uint32_t length, const uint8_t *pub
{
uint32_t i;
for (i = 0; i < (uint32_t)length; ++i) {
for (i = 0; i < length; ++i) {
if (id_equal(public_key, list[i].public_key)) {
return i;
}
@ -710,7 +710,7 @@ END_TEST
static void dht_pack_unpack(const Node_format *nodes, size_t size, uint8_t *data, size_t length)
{
uint16_t packed_size = pack_nodes(data, length, nodes, size);
int16_t packed_size = pack_nodes(data, length, nodes, size);
ck_assert_msg(packed_size != -1, "Wrong pack_nodes result");
uint16_t processed = 0;