Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle cleanup: Remove implicit bool conversions. #2631

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .restyled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ exclude:

restylers:
- astyle:
image: restyled/restyler-astyle:d7967bcb8b622a98524b7df1da1b02652114cf9a
arguments: ["--options=other/astyle/astylerc"]
include:
- "**/*.c"
- "**/*.h"
- autopep8
- black
- clang-format:
image: restyled/restyler-clang-format:13.0.1
image: restyled/restyler-clang-format:v16.0.6
include:
- "**/*.cc"
- "**/*.hh"
Expand Down
3 changes: 1 addition & 2 deletions auto_tests/TCP_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ static void test_client_invalid(void)
ip_port_tcp_s.port = net_htons(ports[random_u32(rng) % NUM_PORTS]);
ip_port_tcp_s.ip = get_loopback();
TCP_Client_Connection *conn = new_tcp_connection(logger, mem, mono_time, rng, ns, &ip_port_tcp_s,
self_public_key, f_public_key, f_secret_key, nullptr);
self_public_key, f_public_key, f_secret_key, nullptr);

// Run the client's main loop but not the server.
mono_time_update(mono_time);
Expand Down Expand Up @@ -709,7 +709,6 @@ static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t
return 0;
}


static void test_tcp_connection(void)
{
const Random *rng = os_random();
Expand Down
1 change: 0 additions & 1 deletion auto_tests/announce_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ static void basic_announce_tests(void)
test_store_data();
}


int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);
Expand Down
1 change: 0 additions & 1 deletion auto_tests/auto_test_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin
}
}


void print_debug_logger(void *context, Logger_Level level, const char *file, int line, const char *func, const char *message, void *userdata)
{
print_debug_log(nullptr, (Tox_Log_Level) level, file, (uint32_t) line, func, message, userdata);
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/auto_test_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void print_debug_log(Tox *m, Tox_Log_Level level, const char *file, uint32_t lin

// Use this function when setting the log callback on a Logger object
void print_debug_logger(void *context, Logger_Level level, const char *file, int line,
const char *func, const char *message, void *userdata);
const char *func, const char *message, void *userdata);

Tox *tox_new_log(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data);
Tox *tox_new_log_lan(struct Tox_Options *options, Tox_Err_New *err, void *log_user_data, bool lan_discovery);
Expand Down
1 change: 0 additions & 1 deletion auto_tests/conference_av_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ static void test_groupav(AutoTox *autotoxes)
ck_assert_msg(tox_conference_invite(autotoxes[0].tox, 0, 0, nullptr) != 0, "failed to invite friend");
((State *)autotoxes[0].state)->invited_next = true;


printf("waiting for invitations to be made\n");
uint32_t invited_count = 0;

Expand Down
2 changes: 0 additions & 2 deletions auto_tests/conference_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ static bool names_propagated(uint32_t tox_count, AutoTox *autotoxes)
return true;
}


/**
* returns a random index at which a list of booleans is false
* (some such index is required to exist)
Expand Down Expand Up @@ -357,7 +356,6 @@ static void test_many_group(AutoTox *autotoxes)
nullptr) != 0,
"failed to set group title");


printf("waiting for invitations to be made\n");
uint32_t invited_count = 0;

Expand Down
8 changes: 4 additions & 4 deletions auto_tests/dht_getnodes_api_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ static void test_dht_getnodes(AutoTox *autotoxes)
tox_events_callback_dht_get_nodes_response(autotoxes[i].dispatch, getnodes_response_cb);

printf("Peer %zu dht closenode count total/announce-capable: %d/%d\n",
i,
tox_dht_get_num_closelist(autotoxes[i].tox),
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox)
);
i,
tox_dht_get_num_closelist(autotoxes[i].tox),
tox_dht_get_num_closelist_announce_capable(autotoxes[i].tox)
);
}

while (!all_nodes_crawled(autotoxes, NUM_TOXES, public_key_list)) {
Expand Down
1 change: 0 additions & 1 deletion auto_tests/encryptsave_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ static void test_keys(void)
free(in_plaintext2a);
free(out_plaintext2a);


uint8_t encrypted2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
ret = tox_pass_encrypt(string, 44, key_char, 12, encrypted2, &encerr);
ck_assert_msg(ret, "generic failure 3: %d", encerr);
Expand Down
6 changes: 2 additions & 4 deletions auto_tests/file_streaming_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,13 @@ static void tox_file_chunk_request(Tox *tox, uint32_t friend_number, uint32_t fi
Tox_Err_File_Send_Chunk error;
tox_file_send_chunk(tox, friend_number, file_number, position, f_data, length, &error);


ck_assert_msg(error == TOX_ERR_FILE_SEND_CHUNK_OK,
"could not send chunk, error num=%d pos=%d len=%d", (int)error, (int)position, (int)length);

++sending_num;
sending_pos += length;
}


static uint8_t num;
static bool file_recv;
static void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t position, const uint8_t *data,
Expand Down Expand Up @@ -225,8 +223,8 @@ static void file_transfer_test(void)
tox_callback_file_recv(tox3, tox_file_receive);
const uint64_t totalf_size = UINT64_MAX;
Tox_File_Number fnum = tox_file_send(
tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
tox2, 0, TOX_FILE_KIND_DATA, totalf_size, nullptr,
(const uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), nullptr);
ck_assert_msg(fnum != UINT32_MAX, "tox_new_file_sender fail");

Tox_Err_File_Get gfierr;
Expand Down
1 change: 0 additions & 1 deletion auto_tests/file_transfer_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ static void tox_file_chunk_request(Tox *tox, const Tox_Event_File_Chunk_Request
sending_pos += length;
}


static uint8_t num;
static bool file_recv;
static void write_file(Tox *tox, const Tox_Event_File_Recv_Chunk *event, void *user_data)
Expand Down
2 changes: 0 additions & 2 deletions auto_tests/forwarding_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,13 @@ static void test_forwarding(void)
}
}


for (uint32_t i = 0; i < NUM_FORWARDER; ++i) {
kill_forwarding_subtox(mem, subtoxes[i]);
}

tox_kill(relay);
}


int main(void)
{
setvbuf(stdout, nullptr, _IONBF, 0);
Expand Down
1 change: 0 additions & 1 deletion auto_tests/group_general_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ static void group_announce_test(AutoTox *autotoxes)
iterate_all_wait(autotoxes, NUM_GROUP_TOXES, ITERATION_INTERVAL);
}


printf("All tests passed!\n");
}

Expand Down
4 changes: 2 additions & 2 deletions auto_tests/group_message_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ static void group_message_test(AutoTox *autotoxes)

if (state1->peer_joined && !state1->message_sent) {
state1->pseudo_msg_id = tox_group_send_message(
tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE,
TEST_MESSAGE_LEN, &err_send);
tox1, group_number, TOX_MESSAGE_TYPE_NORMAL, (const uint8_t *)TEST_MESSAGE,
TEST_MESSAGE_LEN, &err_send);
ck_assert(err_send == TOX_ERR_GROUP_SEND_MESSAGE_OK);
state1->message_sent = true;
}
Expand Down
1 change: 0 additions & 1 deletion auto_tests/group_moderation_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ typedef struct State {
char mod_name1[TOX_MAX_NAME_LENGTH];
char mod_name2[TOX_MAX_NAME_LENGTH];


bool observer_check;
size_t observer_event_count;
char observer_name1[TOX_MAX_NAME_LENGTH];
Expand Down
1 change: 0 additions & 1 deletion auto_tests/group_save_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ static void group_save_test(AutoTox *autotoxes)
tox_group_self_get_public_key(tox0, group_number, founder_pk, &sq_err);
ck_assert(sq_err == TOX_ERR_GROUP_SELF_QUERY_OK);


Tox_Err_Group_Invite_Friend err_invite;
tox_group_invite_friend(tox0, group_number, 0, &err_invite);

Expand Down
1 change: 0 additions & 1 deletion auto_tests/group_tcp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ static void group_tcp_test(AutoTox *autotoxes)
printf("%d peers successfully joined. Waiting for code...\n", NUM_GROUP_TOXES);
printf("Tox 0 sending secret code to all peers\n");


for (size_t i = 0; i < NUM_GROUP_TOXES - 1; ++i) {

Tox_Err_Group_Send_Private_Message perr;
Expand Down
2 changes: 0 additions & 2 deletions auto_tests/onion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ static int handle_test_3(void *object, const IP_Port *source, const uint8_t *pac
return 1;
}


if (memcmp(packet + 1, sb_data, ONION_ANNOUNCE_SENDBACK_DATA_LENGTH) != 0) {
return 1;
}
Expand Down Expand Up @@ -154,7 +153,6 @@ static int handle_test_3_old(void *object, const IP_Port *source, const uint8_t
return 1;
}


if (memcmp(packet + 1, sb_data, ONION_ANNOUNCE_SENDBACK_DATA_LENGTH) != 0) {
return 1;
}
Expand Down
16 changes: 8 additions & 8 deletions auto_tests/proxy_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ static bool try_bootstrap(Tox *tox1, Tox *tox2, Tox *tox3, Tox *tox4)
tox_self_get_connection_status(tox3) != TOX_CONNECTION_NONE &&
tox_self_get_connection_status(tox4) != TOX_CONNECTION_NONE) {
printf("%d %d %d %d\n",
tox_self_get_connection_status(tox1),
tox_self_get_connection_status(tox2),
tox_self_get_connection_status(tox3),
tox_self_get_connection_status(tox4));
tox_self_get_connection_status(tox1),
tox_self_get_connection_status(tox2),
tox_self_get_connection_status(tox3),
tox_self_get_connection_status(tox4));
return true;
}

Expand All @@ -38,10 +38,10 @@ static bool try_bootstrap(Tox *tox1, Tox *tox2, Tox *tox3, Tox *tox4)

if (i % 10 == 0) {
printf("%d %d %d %d\n",
tox_self_get_connection_status(tox1),
tox_self_get_connection_status(tox2),
tox_self_get_connection_status(tox3),
tox_self_get_connection_status(tox4));
tox_self_get_connection_status(tox1),
tox_self_get_connection_status(tox2),
tox_self_get_connection_status(tox3),
tox_self_get_connection_status(tox4));
}

c_sleep(tox_iteration_interval(tox1));
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/save_friend_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(void)
ck_assert(tox2 != nullptr);

tox_events_init(tox1);
Tox_Dispatch* dispatch1 = tox_dispatch_new(nullptr);
Tox_Dispatch *dispatch1 = tox_dispatch_new(nullptr);
ck_assert(dispatch1 != nullptr);

printf("bootstrapping tox2 off tox1\n");
Expand Down
5 changes: 2 additions & 3 deletions auto_tests/save_load_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static void test_few_clients(void)
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
tox_options_free(opts1);
tox_events_init(tox1);
Tox_Dispatch* dispatch1 = tox_dispatch_new(nullptr);
Tox_Dispatch *dispatch1 = tox_dispatch_new(nullptr);
ck_assert(dispatch1 != nullptr);

struct Tox_Options *opts2 = tox_options_new(nullptr);
Expand All @@ -164,7 +164,7 @@ static void test_few_clients(void)
Tox *tox2 = tox_new_log(opts2, &t_n_error, &index[1]);
ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "Failed to create tox instance: %d", t_n_error);
tox_events_init(tox2);
Tox_Dispatch* dispatch2 = tox_dispatch_new(nullptr);
Tox_Dispatch *dispatch2 = tox_dispatch_new(nullptr);
ck_assert(dispatch2 != nullptr);

struct Tox_Options *opts3 = tox_options_new(nullptr);
Expand All @@ -175,7 +175,6 @@ static void test_few_clients(void)

ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances");


Time_Data time_data;
ck_assert_msg(pthread_mutex_init(&time_data.lock, nullptr) == 0, "Failed to init time_data mutex");
time_data.clock = current_time_monotonic(tox1->mono_time);
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/set_name_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
static void nickchange_callback(Tox *tox, const Tox_Event_Friend_Name *event, void *user_data)
{
//const uint32_t friend_number = tox_event_friend_name_get_friend_number(event);
const uint8_t* name = tox_event_friend_name_get_name(event);
const uint8_t *name = tox_event_friend_name_get_name(event);
const uint32_t name_length = tox_event_friend_name_get_name_length(event);

ck_assert_msg(name_length == sizeof(NICKNAME), "Name length not correct: %d != %d", (uint16_t)name_length,
Expand Down
1 change: 0 additions & 1 deletion auto_tests/tox_many_tcp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ static void test_many_clients_tcp_b(void)
printf("test_many_clients_tcp_b succeeded, took %llu seconds\n", time(nullptr) - cur_time);
}


static void tox_suite(void)
{
/* Each tox connects to a single tox TCP */
Expand Down
1 change: 0 additions & 1 deletion auto_tests/tox_many_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ static void accept_friend_request(Tox *m, const Tox_Event_Friend_Request *event,
}
}


#define TCP_TEST_NUM_TOXES 90
#define TCP_TEST_NUM_FRIENDS 50

Expand Down
3 changes: 2 additions & 1 deletion auto_tests/tox_new_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#include "../toxcore/ccompat.h"

int main(void) {
int main(void)
{
tox_kill(tox_new(nullptr, nullptr));
return 0;
}
5 changes: 0 additions & 5 deletions auto_tests/toxav_basic_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#define TEST_STOP_RESUME_PAYLOAD 1
#define TEST_PAUSE_RESUME_SEND 1


#define ck_assert_call_control(a, b, c) do { \
Toxav_Err_Call_Control cc_err; \
bool ok = toxav_call_control(a, b, c, &cc_err); \
Expand All @@ -34,7 +33,6 @@
ck_assert(cc_err == TOXAV_ERR_CALL_CONTROL_OK); \
} while (0)


typedef struct {
bool incoming;
uint32_t state;
Expand All @@ -46,7 +44,6 @@ static void clear_call_control(CallControl *cc)
*cc = empty;
}


/**
* Callbacks
*/
Expand Down Expand Up @@ -89,7 +86,6 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const
}
}


/**
* Iterate helper
*/
Expand Down Expand Up @@ -207,7 +203,6 @@ static void test_av_flows(void)
c_sleep(20);
}


{
Toxav_Err_New error;
alice_av = toxav_new(alice, &error);
Expand Down
2 changes: 0 additions & 2 deletions auto_tests/toxav_many_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ static void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const
}
}


/**
* Iterate helper
*/
Expand Down Expand Up @@ -299,7 +298,6 @@ static void test_av_three_calls(void)
}
}


do {
tox_iterate(bootstrap, nullptr);
tox_iterate(alice, nullptr);
Expand Down
Loading
Loading